画隐函数图像的办法

2020-07-15 14:44发布

## 我的问题 如何画$f(x,y)=0$之类的隐函数呢(比如$x^2+y^3+xy=2$的图像),我看TikZ文档里好像不太推荐使用外部程序的样子,集思广益一下,谢谢大家!

## 我的问题 如何画$f(x,y)=0$之类的隐函数呢(比如$x^2+y^3+xy=2$的图像),我看TikZ文档里好像不太推荐使用外部程序的样子,集思广益一下,谢谢大家!
2条回答
TikZ并没有不推荐使用外部程序,只是说明了使用TikZ作图的优势:一致性 这里使用了`gnuplot`作隐函数图像 ![](https://wenda.latexstudio.net/data/attach/200715/ySFH977r.png) ```tex \documentclass[border=1cm]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.17} \begin{document} \begin{tikzpicture} \begin{axis}[ axis x line = middle, axis y line = middle, xlabel = {$x$}, ylabel = {$y$}, xmin=-16, xmax=16, ymin=-12, ymax=7, legend pos=outer north east, legend style={draw=none}, ] \addplot +[no markers, raw gnuplot, thick, red, empty line = jump % not strictly necessary, as this is the default behaviour in the development version of PGFPlots ] gnuplot { set xrange [-15:15]; set yrange [-11:6]; set contour base; set cntrparam levels discrete 0.003; unset surface; set view map; set isosamples 500; set samples 500; splot x^2 + x*y + y^3 - 2; }; \addplot +[no markers, raw gnuplot, thick, blue, empty line = jump % not strictly necessary, as this is the default behaviour in the development version of PGFPlots ] gnuplot { set xrange [-15:15]; set yrange [-11:6]; set contour base; set cntrparam levels discrete 0.003; unset surface; set view map; set isosamples 500; set samples 500; splot exp(sqrt(x)+y) + cos(x) -1/x; }; \legend{$x^2 + xy + y^3=0$, $\exp(\sqrt{x}+y) + \cos x - 1/x$} \end{axis} \end{tikzpicture} \end{document} ```

一周热门 更多>