fillbetween 导致非法计量单位(pt 插入)

fillbetween 导致非法计量单位(pt 插入)

这很有效:

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
%\usepgfplotslibrary{fillbetween}
\begin{document}

\begin{tikzpicture}[
declare function={
func(\x)=(\x<=0)*(1)    +
and(\x>0, \x<1)*(1) +
and(\x>=1, \x<=1.75)*(2)    +
and(\x>1.75, \x<3)*(1)  +
(\x>=3)*(0);
}
]
\begin{axis}[
xmin=0,   xmax=3,
ymin=0,   ymax=3,
ticks=none,
axis x line=bottom,
axis y line=left,
xlabel=$t$, ylabel=$n_t$,
enlargelimits=false
]
\addplot[blue, domain=0:3, samples=200]{func(x)};
\end{axis}
\end{tikzpicture} 
\end{document}

但是如果我取消注释第五行,就会出现错误Illegal unit of measure (pt inserted). <to be read again>。我fillbetween在文档的另一部分使用该包,效果很好。

相关内容