如何在 Gnuplot 上以 f(x,y)=0 的形式绘制特定解

How to plot a particular solution in the form f(x,y)=0 on Gnuplot

我需要在Gnuplot上绘制一个与0相交的二元函数,即:f(x,y)=0。这将意味着 2D 图而不是 3D。 我到目前为止的尝试是:

set term cairolatex eps standalone size 6in,6in lw 7
set key box opaque samplen 6
set key spacing 1.5
set key Right
set key height 2
set key width 3
f(x,y)=...
set output 'V.tex'
plot f(x,y)=0 title '\small${\hat{V}=2}$' lc rgb "black"
set out

但它returns 函数绘制预期

以防万一,http://www.gnuplot.info/faq/faq.html 中 Gnuplot 常见问题解答的 5.2 部分中给出的 解决方法 不会生成我可以编译的 .tex 文件。

这在 gnuplot FAQ 中有记录:http://www.gnuplot.info/faq/faq.html

来自该页面:

5.2 Implicit defined graphs

Implicit graphs or curves cannot be plotted directly in gnuplot . However there is a workaround.

gnuplot> # An example. Place your definition in the following line:  
gnuplot> f(x,y) = y - x**2 / tan(y)  
gnuplot> set contour base  
gnuplot> set cntrparam levels discrete 0.0  
gnuplot> unset surface  
gnuplot> set table $TEMP  
gnuplot> splot f(x,y)  
gnuplot> unset table  
gnuplot> plot $TEMP w l

The trick is to draw the single contour line z=0 of the surface z=f(x,y), and store the resulting contour curve to a temporary file or datablock.

我尝试将常见问题解答(@gdupras 的回答)中的代码与您最初显示的代码结合起来。

set term cairolatex eps standalone size 6in,6in lw 7
set key box opaque samplen 6
set key spacing 1.5
set key Right
set key height 2
set key width 3

f(x,y) = y - x**2 / tan(y)  
set contour base  
set cntrparam levels discrete 0.0  
unset surface  
set table $TEMP  
splot f(x,y)  
unset table  

set output 'V.tex'
plot $TEMP w l title '\small${\hat{V}=2}$' lc rgb "black"
set out

在我的环境下,这段代码生成“V.tex”,编译后得到下图(PDF转PNG)