绘制水平曲线

绘制水平曲线

如何让 TikZ 绘制水平曲线x^{2}y + xy^{2} = 1

\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}

\begin{document}

\begin{tikzpicture}
\begin{axis}[width=6in,axis equal image,clip=false,
    axis lines=middle,
    xmin=-5,xmax=5,
    domain=-5:5, samples=201,
    xlabel=$x$,ylabel=$y$,
    ymin=-5,ymax=5,
    restrict y to domain=-5:5,
    enlargelimits={abs=1cm},
    axis line style={latex-latex},
    ticklabel style={font=\tiny,fill=white},
    xtick={\empty},ytick={\empty},
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west}
]
\addplot[samples=501,domain=-0.7854:0.7854,blue] {};
\end{axis}
\end{tikzpicture}

\end{document}

答案1

您可以使用contour gnuplot此功能gnuplot作为执行实际计算的后端。

要编译该文档,您需要gnuplot在系统上安装并启用 shell 转义(例如pdflatex -shell-escape filename)。PGFPlots 会自动进行必要的gnuplot调用。

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}

\begin{document}

\begin{tikzpicture}
\begin{axis}[view={0}{90}]
\addplot3 [
    very thick,
    contour gnuplot={
        levels=1,
        labels=false,
        draw color=black
    },
    samples=50
] {x^2*y + x*y^2};
\end{axis}
\end{tikzpicture}

\end{document}

相关内容