提问于:
浏览数:
3971
用 `pgfplot` 画 x^(1/3) 或 x^(2/3) 的图像,x 正半轴正常显示,但是负半轴的部分报错,并且不显示。
MWE:
```
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel={$x$}, ylabel={$y$},
xmin=-4, xmax=4,
ymin=-10, ymax=10,
line width=1pt,
axis lines=center,
]
\addplot[smooth, domain=0:2.5, cyan!70]{x^(1/2)};
\addplot[smooth, domain=0:2.5, cyan!70]{-x^(1/2)};
\addplot[smooth,domain=-2.5:0, red!70]{x^(1/3)};
\addplot[smooth,domain=2.5:0, red!70]{x^(1/3)};
\end{axis}
node [above] at (2.3,3.1){$y=x^{1/3}$};
\end{tikzpicture}
\end{document}
```
出来的结果如图所示(红色线):
![![](https://pics.latexstudio.net/data/images/201912/c27a2c9a63a8c66.jpg)](https://pics.latexstudio.net/data/images/201912/c27a2c9a63a8c66.jpg)
左半部分没有显示,报错:
```
NOTE: coordinate (2Y2.083487e-1],3Y0.0e0]) has been dropped because it is unbou
nded (in y). (see also unbounded coords=jump).
NOTE: coordinate (2Y1.041827e-1],3Y0.0e0]) has been dropped because it is unbou
nded (in y). (see also unbounded coords=jump).
NOTE: coordinate (2Y1.67e-5],3Y0.0e0]) has been dropped because it is unbounded
(in y). (see also unbounded coords=jump).
Package pgfplots Warning: the current plot has no coordinates (or all have been
filtered away) on input line 20.
```![](https://pics.latexstudio.net/data/images/201912/c27a2c9a63a8c66.jpg)