我正在尝试使用下面的代码绘制图形 (x+2)^{1/2}(x-7)^{2/3},但编译后轴存在,但图为空。有人能指出我遗漏了什么吗?任何帮助都将不胜感激。谢谢!
\begin{tikzpicture}[thick]
\begin{axis}[
axis lines = center,
legend pos = outer north east,
xlabel = $x$,
ylabel = $y$,
]
%Below the red parabola is defined
\addplot [
domain=-5:5,
samples=100,
color=red,
]
{(x+2)^(1/3)*(x-7)^(2/3)};
\end{axis}
\end{tikzpicture}
答案1
详情Pgfplots:无法绘制一些常见的数学函数,问题在于立方根和其他分数幂是使用对数函数计算的;因此,你不能(x-2)^(1/3)
直接对负数生成,但你可以使用
abs(x-2)/(x-2)*abs(x-2)
那就很好了,只要x\ne 2
……
% arara: pdflatex
% !arara: indent: {overwrite: yes}
\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}[thick]
\begin{axis}[
axis lines = center,
legend pos = outer north east,
xlabel = $x$,
ylabel = $y$,
]
%Below the red parabola is defined
\addplot [
domain=-5:5,
samples=100,
color=red,
]
{abs(x+2)/(x+2)*abs((x+2))^(1/3)*abs(x-7)/(x-7)*abs(x-7)^(2/3)};
\end{axis}
\end{tikzpicture}
\end{document}