如果你评论\pgfplotsset{compat=1.10}
这行 MWE:
\documentclass{amsart}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=newest}
\pgfplotsset{compat=1.10}
\begin{document}
\begin{tikzpicture}
\begin{axis}[width=10cm,height=8cm, scale only axis, axis x line=middle,axis y line=middle, samples=300, disabledatascaling, enlargelimits,
xmin=-2,xmax=2,xtick={-2,-1.5,...,2}, xticklabels={$-\dfrac{2\pi}{T}$, $-\dfrac{1{,}5\pi}{T}$, $-\dfrac{\pi}{T}$, $-\dfrac{\pi}{2T}$, ,$\dfrac{\pi}{2T}$, $\dfrac{\pi}{T}$, $\dfrac{1{,}5\pi}{T}$, $\dfrac{2\pi}{T}$}, xlabel={$\omega$},
ymin=0,ymax=5.25,ytick={2.5,5},yticklabels={$T/2$, $T$}, ylabel={$P(\omega)$}, y tick label style={yshift=0.2cm},
legend style={draw=white, at={(1,1)}, anchor=north east},legend cell align=left]
%alpha=0
\addplot [line width=1pt, color=blue, domain=-5:5, xscale=1, yscale=5] (-1,0) -- (-1,1) -- (1,1) -- (1,0) ;
\addlegendentry{$\alpha=0$};
%alpha=0.5
\addplot [line width=1pt, color=red, domain=-1.5:-0.5, xscale=1, yscale=5, forget plot=true] {0.5*(1+cos(deg(-x*pi-0.5*pi)))} -- (0.5,1);
\addplot [line width=1pt, color=red, domain=0.5:1.5, xscale=1, yscale=5] {0.5*(1+cos(deg(x*pi-0.5*pi)))} ;
\addlegendentry{$\alpha=0.5$};
%alpha=1
\addplot [line width=1pt, color=black, domain=-2:2, xscale=1, yscale=5] {0.5*(1+cos(deg(0.5*pi*x)))} ;
\addlegendentry{$\alpha=1$};
\end{axis}
\end{tikzpicture}
\end{document}
结果截然不同:很糟糕。有什么帮助吗?
这是最新的结果:
这是最古老的:
答案1
pgfplots
版本 1.12中有一个已知问题,但该forget plot
选项和 LuaTeX 存在。此问题已在版本 1.12.1 中修复,该版本已发布到 CTAN,预计会在适当的时候在 TeX Live 2015 和 MiKTeX 2.9 中提供。