如何使用 tex 绘制带有矢量和点的绘图曲线

如何使用 tex 绘制带有矢量和点的绘图曲线

我如何使用 tex 和这些矢量和点绘制这条曲线。

在此处输入图片描述

答案1

这里有一个基本猜测初始点

\documentclass[tikz,margin=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{
    compat=1.16,
    drawline/.style={-,black},
    drawarrows/.style={
        stealth-,
        blue!50!green,
        point meta=rawx,
        quiver={
            u=-x,
            v=-y,
            every arrow/.append style={
                opacity={
                    ifthenelse(
                        (\coordindex==#1 || -1==#1),
                        \coordindex/\pgfkeysvalueof{/pgfplots/samples},
                        0
                    )
                },
            },
        },
        mark=*,mark size=1pt,mark options={fill=black,draw=black},
        %nodes near coords=\pgfmathprintnumber{\coordindex},
        %node near coords style={above,font=\tiny,
        %opacity={ifthenelse((\coordindex==#1 || -1==#1),1,0)}},
    },
    customaxis/.style={
        domain=pi/2:4*pi,
        samples=200,
        width=5cm,
        height=5cm,
        scale only axis,
        axis x line=center,
        axis y line=center,
        xtick=\empty,
        ytick=\empty,
        enlargelimits=true,
        xlabel={$x$},
        ylabel={$y$},
        clip=false,
    },
}
\begin{document}
    \begin{tikzpicture}
        \begin{axis}[customaxis]
            \addplot[drawline] ({cos(deg(x))},{x^2});
            \addplot[drawarrows=100] ({cos(deg(x))},{x^2});
        \end{axis}
    \end{tikzpicture}

    \begin{tikzpicture}
        \begin{axis}[customaxis]
            \addplot[drawline] ({cos(deg(x))},{x^2})
            node[below right,pos=0] {$t=-1$}
            node[below right,pos=0.2] {$t=0$}
            node[above,pos=0.4] {$t=1$}
            node[above left,pos=0.6] {$t=2$}
            node[above left,pos=0.8] {$t=3$}
            node[above,pos=1] {$t=4$};

            \addplot[drawarrows=-1] ({cos(deg(x))},{x^2});
        \end{axis}
    \end{tikzpicture}
\end{document}

在此处输入图片描述

附录只是因为它看起来不错(我的新头像)

\documentclass[tikz,margin=3mm]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{colormaps}
\usetikzlibrary{arrows.meta}
\pgfplotsset{
    compat=1.16,
    drawarrows/.style={
        Circle-,thick,point meta={\pgfkeysvalueof{/pgfplots/samples}-\coordindex},
        quiver={u=-x,v=-y,colored=mapped color},
        },
    customaxis/.style={
        domain=9*pi/2:pi/2,
        samples=1000,
        width=5cm,
        height=5cm,
        scale only axis,
        clip=false,
        hide axis,
        colormap/hsv,
    },
}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[customaxis]
        \addplot[drawarrows] ({cos(deg(x))},{x^2});
    \end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

tkz-fct并不是完成这类工作的理想工具,但你可以尝试在此处输入图片描述

\documentclass{standalone} 
\usepackage{tkz-euclide,tkz-fct}

\begin{document} 

\begin{tikzpicture}[scale=1.25]
  \tkzInit[xmin=-50,xmax=50,xstep=10,
           ymin=-50,ymax=50,ystep=10]
   \tkzDefPoint(0,0){O}
  \tkzFctPar[smooth,samples=200,domain=0:50]{t*sin(t)}{t*cos(t)} 
\foreach \t [count=\i] in {0,10,...,50}{
\def\xt{\t*sin(\t)}
\def\yt{\t*cos(\t)}  
\tkzDefPoint(\xt,\yt){a\i}
\tkzDrawPoint(a\i)
\tkzDrawSegment[->](O,a\i)
}
\end{tikzpicture}

\end{document}

相关内容