基于 asymptote 的方案,需要安装 asymptote (貌似还有其他依赖,自行 texdoc asymptote 吧)同时需要编译三次(假设保持文件为 test.tex):
xelatex test.tex
asy test-1.asy
xelatex test.tex效果如下:
完整代码:
\documentclass[border=10pt]{standalone}
% ========= 绘图 ========= %
\usepackage{asymptote}
\begin{document}
\begin{asy}
settings.outformat="pdf"; unitsize(1cm);
import contour; import graph;
real d=1e-5;
real f(real x, real y) {
return 16/((x+2)^2) - (x-2)^2 - y^2;
}
pair a=(-2+d,-4); pair b=(4,4);
real[] ra=new real[] {0};
guide[][] thegraphs=contour(f,a,b,ra,nx=500,join=operator ..);
axes("$x$","$y$",min=a,max=b,arrow=Arrow(TeXHead));
draw(thegraphs[0]);
\end{asy}
\end{document}图形右边倒是没有什么问题
不过在 (0,0) 附近 join=operator .. 表现得并不是那么好
使用 join=operator -- 然后取 nx=600 会好一点:

















问 用`tikz`中的`polt`绘制`y=sqrt{16/(x+2)^2-(x-2)^2}`的图像时最右端部分无法闭合?