通过改变在 pgfplots 中绘制此类图的样本值,图的形状发生了很大变化;是因为绘制图时存在一些不稳定性还是函数有这样的行为?这种变化从何而来?
% pdflatex
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\pgfmathdeclarefunction{R}{1}{\pgfmathparse{(sin(deg(#1))*sqrt(abs(cos(deg(#1)))))/(sin(deg(#1))+8/5)-1.5*sin(deg(#1))+1.5}}
\begin{axis}
[hide axis,scale=0.3,title=10]
\addplot [domain=0:2*pi,samples=10,data cs=polarrad,solid, thick,red,fill=red,smooth] {R(x)};
\end{axis}
\hspace*{3cm}
\begin{axis}
[hide axis,scale=0.3,title=50]
\addplot [domain=0:2*pi,samples=50,data cs=polarrad,solid, thick,red,fill=red,smooth] {R(x)};
\end{axis}
\hspace*{3cm}
\begin{axis}
[hide axis,scale=0.3,title=100]
\addplot [domain=0:2*pi,samples=100,data cs=polarrad,solid, thick,red,fill=red,smooth] {R(x)};
\end{axis}
\hspace*{3cm}
\begin{axis}
[hide axis,scale=0.3,title=500]
\addplot [domain=0:2*pi,samples=500,data cs=polarrad,solid, thick,red,fill=red,smooth] {R(x)};
\end{axis}
\hspace*{3cm}
\begin{axis}
[hide axis,scale=0.3,title=1000]
\addplot [domain=0:2*pi,samples=1000,data cs=polarrad,solid, thick,red,fill=red,smooth] {R(x)};
\end{axis}
\end{tikzpicture}
\end{document}
即使在样本值较高的情况下,我们也能看到存在一些变化:
答案1
这是一个更好的方法。
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\pgfmathdeclarefunction{R}{1}{\pgfmathparse{(sin(deg(#1))*sqrt(abs(cos(deg(#1)))))/(sin(deg(#1))+8/5)-1.5*sin(deg(#1))+1.5}}
\begin{axis}
[hide axis,scale=0.3,title={20 with bilateral symmetry}]
\addplot [domain=-pi/2:pi/2,samples=10,data cs=polarrad,solid, thick,red,fill=red,smooth] {R(x)};
\addplot [domain=pi/2:3*pi/2,samples=10,data cs=polarrad,solid, thick,red,fill=red,smooth] {R(x)};
\end{axis}
\end{tikzpicture}
\end{document}