z 轴的轴范围几乎为空

z 轴的轴范围几乎为空

这是我的 MWE:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{amsmath}
\pgfplotsset{compat=1.12}

\begin{document}
\begin{figure}[ht]
\centering
\begin{tikzpicture}
\begin{axis}[
    width=0.6\textwidth,
    view={0}{90},
    domain=0:2*pi+0.5,
    y domain=0:2*pi+0.5,
    xmax=2*pi+1, ymax=2*pi+1,
    samples=15,
    axis equal image,
    axis lines = center,
    xtick = {0,3.14,6.28},
    ytick = {0,3.14,6.28},
    xticklabels = {0,$\pi$,$2\pi$},
    yticklabels = {0,$\pi$,$2\pi$}
]
\addplot3 [blue, quiver={u={1}, v={sin(deg(\x))^2}, scale arrows=0.3, every arrow/.append style={-latex}}] (x,y,0);
\addplot [thick, red] {2-sin(deg(\x))*cos(deg(\x))/2+\x/2};
\end{axis}
\end{tikzpicture}
    \caption{Retningsfelt (blå) for $\dfrac{d  x}{d  t}=\sin^2(t)$, med løsningskurve (rød) gennem $x(0)=2$.}
  \label{fig:bvp1}
\end{figure}
\end{document}

我收到错误消息

包 pgfplots 警告:z 的轴范围大约为空;在输入行 29 上将其扩大(它是 [0.0;0.0])。

我尝试过在其他帖子中读到的一些修复方法,但似乎没有任何效果。

答案1

我对你使用的语法有些怀疑。两者似乎都有效,但pgfplots手册中提出的语法与你使用的语法不同。

如需补充信息,请参阅手册第 4.5.8 节“箭头图”(第 90 页)pgfplots

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{amsmath}
\pgfplotsset{compat=1.12}

\begin{document}

Original code
\begin{tikzpicture}
\begin{axis}[
    width=0.6\textwidth,
    view={0}{90},
    domain=0:2*pi+0.5,
    y domain=0:2*pi+0.5,
    xmax=2*pi+1, ymax=2*pi+1,
    samples=15,
    axis equal image,
    axis lines = center,
    xtick = {0,3.14,6.28},
    ytick = {0,3.14,6.28},
    xticklabels = {0,$\pi$,$2\pi$},
    yticklabels = {0,$\pi$,$2\pi$}
]
\addplot3 [blue, quiver={u={1}, v={sin(deg(\x))^2}, scale arrows=0.3, every arrow/.append style={-latex}}] (x,y,0);
\addplot [thick, red] {2-sin(deg(\x))*cos(deg(\x))/2+\x/2};
\end{axis}
\end{tikzpicture}

Modified code
\begin{tikzpicture}
\begin{axis}[
    width=0.6\textwidth,
    view={0}{90},
    domain=0:2*pi+0.5,
    y domain=0:2*pi+0.5,
    xmax=2*pi+1, ymax=2*pi+1,
    samples=15,
    axis equal image,
    axis lines = center,
    xtick = {0,3.14,6.28},
    ytick = {0,3.14,6.28},
    xticklabels = {0,$\pi$,$2\pi$},
    yticklabels = {0,$\pi$,$2\pi$}
]
\addplot3 [blue, quiver={u={1}, v={sin(deg(x))^2}, scale arrows=0.3, every arrow/.append style={-latex}}] {x};
\addplot [thick, red] {2-sin(deg(x))*cos(deg(x))/2+x/2};
\end{axis}
\end{tikzpicture}


\end{document}

在此处输入图片描述

相关内容