我有一个电场线的功能:
set isosamples 55, 55
set contour base
set cntrparam levels incremental -1.6,0.2,1.6
unset surface
splot [-4:4] [-2.2:2.2] (y*(1+1/(x**2 + y**2)))如何将箭头放在这条曲线上,sey在x=2的位置?

发布于 2017-12-20 10:26:34
实现这一目标的一种方法如下:
set isosamples 200, 200
set contour base
unset surface
set cntrparam levels incremental -2,0.2,2
set xr [-4:4]
set yr [-3:3]
x_ref = 2
f(x,y) = (y*(1+1/(x**2 + y**2)))
g(x,y) = 2*x*y / ( (x*x + y*y)**2 + (x*x + y*y) - 2*y*y )
set table 'meta.levels.dat'
splot f(x, y)
set table 'meta.pnts.dat'
splot f(x_ref, y)
unset key
unset table
set terminal pngcairo enhanced size 600, 400
set output 'fig.png'
set style arrow 1 head filled size screen 0.01,30 fixed lc rgb 'dark-red'
set size ratio -1
delta = 0.01
plot \
'meta.levels.dat' w l lc rgb 'black', \
'meta.pnts.dat' every 1:1:0:0:0:0 u (x_ref-delta):($2-g(x_ref,$2)*delta):(delta):(g(x_ref,$2)*delta) with vectors as 1战略是:
f(x,y)),然后通过set table保存到文件中。x值(例如x_ref=2),生成f(x_ref, y)的等高线。由于该函数不依赖于x,生成的等高线将仅仅是与x-轴平行的线,因此为了绘制与f(x,y)轮廓相交的点,只需取每个块的第一个点(每个等高线),然后用x-coordinate设置为x_ref绘制它。g(x,y))。with vectors风格来绘制它。上面,delta参数指定了x-direction中的一个小位移--这是为了实现,箭头的头是可见的。最后,图看起来如下:

https://stackoverflow.com/questions/47885534
复制相似问题