用 `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)

2 回答2

0
因为负数不能开根..之前看人讨论过,`tikz`写了判断为负数不能开根之类的
0
绘制 y = x^a 的函数图像时,内部会先转换为 y = exp(a * ln x),然后计算。在实数范围内,函数 ln x 的定义域是 x > 0,所以在小于零的部分画不出来。 手动做一点变换就可以了 ```tex \addplot[smooth, domain=0:-2.5, red!70] {-(-x)^(1/3)}; ```

你的回答

请登录后回答

你的回答将会帮助更多人,请务必认真回答问题。