在 tikz 中绘制特定的“无公式”图形

在 tikz 中绘制特定的“无公式”图形

我怎样才能画出类似这样的图片tikz?这就是我想要画的。

在此处输入图片描述

答案1

您正在寻找这样的东西吗?

在此处输入图片描述

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}
    
\begin{tikzpicture} 
\begin{axis}[axis lines*=middle, xtick=\empty, ytick=\empty]    
\addplot [smooth,tension=0.9] coordinates {(1,5)(1.5,3)(3.5,2)(5,-4)(6,4)};
\end{axis}
\end{tikzpicture}

\end{document}

你可以插入一些随机点并得到一个连接所有点的图

答案2

纯 TikZ 变体,绘图方式controls

\documentclass[tikz, border=3mm]{standalone}
\usetikzlibrary{arrows.meta,
                intersections}

\begin{document}
    \begin{tikzpicture}[%smooth,scale=0.8
         > = Straight Barb,
dot/.style = {circle, draw, thick, fill=blue, inner sep=2pt,
              label={[fill=white, inner sep=1pt, font=\small]60:#1},
              node contents={},}
                        ]
% axis
\draw[->] (-1,0) -- (6,0) node[below left] {$x$};
\draw[->] (0,-3) -- (0,5) node[below left] {$y$};
% some function
\draw[red, very thick, name path=A]
        (0.5,4) .. controls + (0,-1) and + (-1,0) .. (1.5, 2)
                .. controls + (1,0) and + (-0.5,1.5) .. (3,0)
                .. controls + (0.5,-1.5) and + (-0.5,1) .. (4,-2.5)
                .. controls + (1,-1.5) and + (-1,-2) .. (6,3);
% determine coordinates by intersections
\foreach \x in {1,2}
{
    \path[name path=B\x]   (\x,0) -- ++ (0,5);
    \draw[densely dashed, 
          name intersections={of=A and B\x,by={B\x}}] 
          (B\x) -- (\x,-1pt) node[below, font=\footnotesize] {\x};
}
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容