如何绘制 tikzpicture

如何绘制 tikzpicture

我如何绘制附件?错误:对于 (a) 最后一个椭圆形问题;对于 (b) 旋转、箭头和大小;对于 (c) 仅直线箭头。他们能帮忙吗?

\documentclass{article}
\usepackage[margin=1.5in]{geometry}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,decorations.markings,arrows.meta, bending, decorations.markings,calc}
\usepackage{pgfplots,pgfplotstable}
\usepackage{rotating}
\usepackage{subcaption}
%\pgfplotset{compar=1.15}
\usepackage{pstricks-add}
\psset{plotpoints=500, algebraic, arrowinset=0.2, labelsep=3pt}

\tikzset{
  on each segment/.style={
    decorate,
    decoration={
      show path construction,
      moveto code={},
      lineto code={
        \path [#1]
        (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast);
      },
      curveto code={
        \path [#1] (\tikzinputsegmentfirst)
        .. controls
        (\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb)
        ..
        (\tikzinputsegmentlast);
      },
      closepath code={
        \path [#1]
        (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast);
      },
    },
  },
  mid arrow/.style={postaction={decorate,decoration={
        markings,
        mark=at position .5 with {\arrow[#1]{stealth}}
      }}},
}

\begin{document}
\begin{figure}[htb]
 \centering
 \begin{subfigure}[h]{6.5cm}
\begin{tikzpicture}[scale=.6]
\draw (-4,4) node[left]{4} --  (4,4) -- (4,-4) node[below]{4} -- node[midway,below]{$x$} (-4,-4) node[below]{-4} node[left]{-4} -- node[midway,left]{$\dot{x}$} cycle;
\foreach \x in {-3,...,3}
  \draw (\x cm,-4) -- (\x cm,-3.9){};
\foreach \xx in {-3,...,3}
  \draw (\xx cm,4) -- (\xx cm,3.9){};
\foreach \y in {-3,...,3}
  \draw (-4,\y) -- (-3.9,\y){};
\foreach \yy in {-3,...,3}
  \draw (4,\yy) -- (3.9,\yy){};
\draw[dashed] (-4,0) -- (4,0);
\draw[dashed] (0,-4) -- (0,4);
\draw (0,0) (0,0) circle(.25);
  \path [draw=black,postaction={on each segment={mid arrow=black}}]
  (0,0) circle(.6)
  (0,0) circle(1)
  (0,0) circle(1.75)
  (0,0) ellipse (2.75cm and 2.2cm);
\end{tikzpicture}
  \caption{Stable in the sense of Lyapunov}
 \end{subfigure} \\
 %
 \begin{subfigure}[h]{6.5cm}
\begin{tikzpicture}[scale=.6,
decoration = {markings,mark=at position .84 with
             {\arrowreversed[black]{Latex[length=1.5mm]}}}
                        ]
\draw (-4,4) node[left]{4} --  (4,4) -- (4,-4) node[below]{4} -- node[midway,below]{$x$} (-4,-4) node[below]{-4} node[left]{-4} -- node[midway,left]{$\dot{x}$} cycle;
\foreach \x in {-3,...,3}
  \draw (\x cm,-4) -- (\x cm,-3.9){};
\foreach \xx in {-3,...,3}
  \draw (\xx cm,4) -- (\xx cm,3.9){};
\foreach \y in {-3,...,3}
  \draw (-4,\y) -- (-3.9,\y){};
\foreach \yy in {-3,...,3}
  \draw (4,\yy) -- (3.9,\yy){};
\draw[dashed] (-4,0) -- (4,0);
\draw[dashed] (0,-4) -- (0,4);
\psplot[polarplot, arrows=-, linewidth=.5pt, dotsize=2.5pt]{0}{25}{-1.2*EXP(-x/4)}
\psplot[polarplot, arrows=-, linewidth=.5pt, dotsize=2.5pt]{0}{25}{-1*EXP(-x/4.5)}
\psplot[polarplot, arrows=-, linewidth=.5pt, dotsize=2.5pt]{-1.55}{25}{-1.7*EXP(-x/4.5)}
\psplot[polarplot, arrows=-, linewidth=.5pt, dotsize=2.5pt]{-1.55}{25}{-2*EXP(-x/5)}
\end{tikzpicture}
  \caption{Asymptotically stable}
 \end{subfigure} 
 %
 \begin{subfigure}[h]{6.5cm}
\begin{tikzpicture}[scale=.6]
\draw (-4,4) node[left]{0.4} --  (4,4) -- (4,-4) node[below]{-0.4} -- node[midway,below]{$x$} (-4,-4) node[below]{-0.4} node[left]{-0.4} -- node[midway,left]{$\dot{x}$} cycle;
\foreach \x in {-3,...,3}
  \draw (\x cm,-4) -- (\x cm,-3.9){};
\foreach \xx in {-3,...,3}
  \draw (\xx cm,4) -- (\xx cm,3.9){};
\foreach \y in {-3,...,3}
  \draw (-4,\y) -- (-3.9,\y){};
\foreach \yy in {-3,...,3}
  \draw (4,\yy) -- (3.9,\yy){};
\draw[dashed] (-4,0) -- (4,0);
\draw[dashed] (0,-4) -- (0,4);
\draw (-3.5,-4) .. controls (-2.8,-2) and (-2,-.5) .. (-2.75,2);
\draw (-3,-4) .. controls (-2,-2) and (.5,-.75) .. (-1.5,2.25);
\draw (-3,-4) .. controls (0.25,-.5) and (-.25,-.5) .. (1,-2.5);
\begin{scope}[rotate=180]
\draw (-3.5,-4) .. controls (-2.8,-2) and (-2,-.5) .. (-2.75,2);
\draw (-3,-4) .. controls (-2,-2) and (.5,-.75) .. (-1.5,2.25);
\draw (-3,-4) .. controls (0.25,-.5) and (-.25,-.5) .. (1,-2.5);
\end{scope}
\end{tikzpicture}
  \caption{Unstable (saddle)}
 \end{subfigure} 
\end{figure}

\end{document}

在此处输入图片描述

输出代码; 在此处输入图片描述

答案1

可以使用 创建它们pgfplots。为了添加箭头,可以使用箭图

\documentclass{article}
\usepackage[margin=1.5in]{geometry}
\usepackage{subcaption}
\usepackage{pgfplots} % based on https://tex.stackexchange.com/a/142650
\pgfplotsset{compat=1.16,
    Laxis/.style={
    width=6cm,height=6cm,xmin=-#1,xmax=#1,ymin=-#1,ymax=#1,
    trig format plots=rad,xtick={-#1,0,#1},ytick={-#1,0,#1},
    xticklabels={$-#1$,$x$,$#1$},yticklabels={$-#1$,$\dot x$,$#1$},
    xticklabel style={text height=1em},
    samples=101,variable=\t,
    execute at begin axis={
        \draw[dashed] (-#1,0) -- (#1,0) (0,-#1) -- (0,#1);}}}
\begin{document}
\begin{figure}[htb]
 \centering
 \begin{subfigure}[h]{6.5cm}
  \begin{tikzpicture}[declare function={
      xcomp(\a,\t)=(0.5+0.5*\a)*cos(\t)*(1+\a*0.04*pow(cos(\t),4));
      ycomp(\a,\t)=(0.5+0.5*\a)*sin(\t);
     }]
  \begin{axis}[Laxis=4,domain=0:2*pi]
   \pgfplotsinvokeforeach{0,1,...,4}
   {\addplot[smooth] ({xcomp(#1,t)},{ycomp(#1,t)});
   \addplot[thick,-stealth,samples=2+#1,domain=#1*pi/4:2*pi+#1*pi/4,
    quiver={
          u={-sin(t)}, v={cos(t)}, %<-approximation
          scale arrows=0.1,
      }]
      ({xcomp(#1,t)},{ycomp(#1,t)});
      }
  \end{axis}
  \end{tikzpicture}
  \caption{Stable.}
 \end{subfigure} \\
 %
 \begin{subfigure}[h]{6.5cm}
  \begin{tikzpicture}[declare function={
      xcomp(\t)=0.15*pow(\t,2)*cos(3*\t)/2;
      ycomp(\t)=0.15*pow(\t,2)*sin(3*\t)/2;
      dx(\t)=\t*(0.15*cos(3*\t)-0.225*\t*sin(3*\t));
      dy(\t)=\t*(0.15*sin(3*\t)+0.225*\t*cos(3*\t));
      norm(\t)=sqrt(pow(dx(\t),2)+pow(dy(\t),2));
     }]
  \begin{axis}[Laxis=4,domain=0:2*pi]
   \addplot[smooth] ({xcomp(t)},{ycomp(t)});
   \addplot[thick,stealth-,samples=4,domain=3.5*pi/4:7*pi/4,
    quiver={
          u={dx(t)/norm(t)}, 
          v={dy(t)/norm(t)},
          scale arrows=0.1,
      }]
      ({xcomp(t)},{ycomp(t)});
   \addplot[smooth] ({-xcomp(t)},{-ycomp(t)});
   \addplot[thick,stealth-,samples=4,domain=3*pi/4:7*pi/4,
    quiver={
          u={-dx(t)/norm(t)}, 
          v={-dy(t)/norm(t)},
          scale arrows=0.1,
      }]
      ({-xcomp(t)},{-ycomp(t)});
  \end{axis}
  \end{tikzpicture}
  \caption{Asymptotically stable.}
 \end{subfigure} 
 %
 \begin{subfigure}[h]{6.5cm}
  \begin{tikzpicture}[declare function={
      xcomp(\t)=0.15*sinh(3*\t);
      ycomp(\t)=0.15*cosh(3*\t);
      dx(\t)=0.45*cosh(3*\t);
      dy(\t)=0.45*sinh(3*\t);
      norm(\t)=sqrt(pow(dx(\t),2)+pow(dy(\t),2));
     }]
  \begin{axis}[Laxis=0.4,domain=-0.4:0.4]
   \addplot[smooth] ({xcomp(t)},{ycomp(t)});
   \addplot[thick,-stealth,samples=2,domain=-0.25:0.25,
    quiver={
          u={dx(t)/norm(t)}, 
          v={dy(t)/norm(t)},
          scale arrows=0.01,
      }]    ({xcomp(t)},{ycomp(t)});
   \addplot[smooth] ({ycomp(t)},{xcomp(t)});
   \addplot[thick,-stealth,samples=2,domain=-0.25:0.25,
    quiver={
          u={dy(t)/norm(t)}, 
          v={dx(t)/norm(t)},
          scale arrows=0.01,
      }]    ({ycomp(t)},{xcomp(t)});
   \addplot[smooth] ({-xcomp(t)},{-ycomp(t)});
   \addplot[thick,-stealth,samples=2,domain=-0.25:0.25,
    quiver={
          u={-dx(t)/norm(t)}, 
          v={-dy(t)/norm(t)},
          scale arrows=0.01,
      }]    ({-xcomp(t)},{-ycomp(t)});
   \addplot[smooth] ({-ycomp(t)},{-xcomp(t)});
   \addplot[thick,-stealth,samples=2,domain=-0.25:0.25,
    quiver={
          u={-dy(t)/norm(t)}, 
          v={-dx(t)/norm(t)},
          scale arrows=0.01,
      }]    ({-ycomp(t)},{-xcomp(t)});
  \end{axis}
  \end{tikzpicture}
  \caption{Unstable.}
 \end{subfigure} 
\end{figure}
\end{document}

在此处输入图片描述

相关内容