我想在 Latex 和极坐标中绘制伯努利双纽线 (2D),但我没有合适的代码。在 Octave 或 gnuplot 中绘制可能更容易,但我时间紧迫。有什么帮助吗?
答案1
这是您需要的代码
\documentclass{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{polar}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{compat=1.10}
\pgfdeclarelayer{bg}
\pgfsetlayers{bg,main}
\begin{document}
\begin{tikzpicture}
\begin{polaraxis}[style=black!10,grid style=black!10,ticklabel style=black!50,xticklabel=$\pgfmathprintnumber{\tick}^\circ$ ]
\addplot [name path=A,thick, blue, domain=0:45, samples=50] {2*sqrt(cos(2*x))};
\addplot [thick, red, domain=-45:0, samples=50] {2*sqrt(cos(2*x))};
\addplot [thick, red, domain=135:225, samples=100] {2*sqrt(cos(2*x))};
\draw [name path=B,blue,thick,opacity=.5,dotted] (0:0) -- (0:201);
\tikzfillbetween[on layer=bg,of=A and B]{gray!50}
\end{polaraxis}
\end{tikzpicture}
\end{document}
提供