![以下等式的图形似乎不正确](https://linux22.com/image/350389/%E4%BB%A5%E4%B8%8B%E7%AD%89%E5%BC%8F%E7%9A%84%E5%9B%BE%E5%BD%A2%E4%BC%BC%E4%B9%8E%E4%B8%8D%E6%AD%A3%E7%A1%AE.png)
我正在尝试绘制方程式使用
pgfplots
,其图形应该是一个简单的闭合曲线。我使用了以下代码:
\begin{tikzpicture}[>=stealth]
\begin{axis}[
xmin=-1,xmax=3,
ymin=-2,ymax=2,
y=2cm,
x=2cm,
axis x line=middle,
axis y line=middle,
axis line style=<->,
xlabel={$x$},
ylabel={$y$},
]
\addplot[no marks,blue] expression[domain=0:2,samples=2500]{(2*x^3-x^4)^(0.125)};
\addplot[no marks,blue] expression[domain=0:2,samples=2500]{-(2*x^3-x^4)^(0.125)};
\end{axis}
\end{tikzpicture}
但图表看起来像
尚未关闭。有什么建议吗?
答案1
您可以使用samples at
来确保获得以下积分x=2
:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplotstable}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}[>=stealth]
\begin{axis}[
xmin=-1,xmax=3,
ymin=-2,ymax=2,
y=2cm,
x=2cm,
axis x line=middle,
axis y line=middle,
axis line style=<->,
xlabel={$x$},
ylabel={$y$},
]
\addplot[no marks,blue] expression[samples at={0,0.01,...,0.5,0.6,0.7,...,1.91,1.915,1.92,...,1.99,2}]{(2*x^3-x^4)^(0.125)};
\addplot[no marks,blue] expression[samples at={0,0.01,...,0.5,0.6,0.7,...,1.91,1.92,1.93,...,1.99,2}]{-(2*x^3-x^4)^(0.125)};
\end{axis}
\end{tikzpicture}
\end{document}