余弦图未绘制

余弦图未绘制

由于某种原因,我无法让 cos(x) 图形显示在这张 tikz 图片上。您知道原因吗?

可重现的代码:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{graphicx}
\begin{document}
\begin{figure}[!h]
\begin{center}
\begin{tikzpicture}[scale=1.25]
    \draw[->] (-3,0) -- (9,0) node[right] {$x$};
    \draw[->] (0,-1.2) -- (0,1.2) node[above] {$\dot x=f(x)=\cos x$};
    \draw[color=black, line width=0.5mm] plot[samples=80,id=s4,domain=-3:9] function{cos(x)};
    \coordinate [label=below:$-\frac{\pi}{2}$] (A) at (-pi/2,0);
    \coordinate [label=below:$\frac{\pi}{2}$] (A) at (pi/2,0);
    \coordinate [label=below:$\frac{3\pi}{2}$] (A) at (3*pi/2,0);
    \coordinate [label=below:$\frac{5\pi}{2}$] (A) at (5*pi/2,0);
    \draw[->, line width=0.5mm, color=red] (-pi/2+0.1,0) -- (-0.1,0);
    \draw[->, line width=0.5mm,color=red] (0.1,0) -- (pi/2-0.1,0);
    \draw[->, line width=0.5mm,color=red] (3*pi/2+0.1,0) -- (2*pi-0.1,0);
    \draw[->, line width=0.5mm,color=red] (2*pi+0.1,0) -- (5*pi/2-0.1,0);
    \draw[->, line width=0.5mm,color=blue] (pi-0.1,0) -- (pi/2+0.1,0);
    \draw[->, line width=0.5mm,color=blue] (3*pi/2-0.1,0) -- (pi+0.1,0);
\end{tikzpicture}
\caption{Vector field on a line "phase portrait".}
\end{center}
\end{figure}
\end{document}

相关内容