具有2d点的GnuPlot splot函数

时间:2017-03-27 18:50:40

标签: gnuplot

我基本上想画2d色面(或等高线图)  rosenbrock函数f(x,y)=(a-x)^ 2 + b *(y-x * x)^ 2 并在此图像上附加一些点(x,y)。

带点的示例文件如下所示:

#x #y
15.00000 12.00000
8.00000 9.00000

问题是,两个图形在输出图像上不共享相同的坐标系:

coordinate systems do not overlap on each other

gnuplot代码:

    #!/usr/bin/env gnuplot
    reset
    set terminal png size 700,700
    enhanced set output 'output.png'
    set tmargin screen 1
    set bmargin screen 0
    set border 0 back
    set size square
    xr=20
    yr=20
    set xrange [-xr:xr]
    set yrange [-yr:yr]
    unset key #disablegraph name 
    unset colorbox 
    set surface
     set multiplot
    set view map
    set cntrparam levels 10# contour tenderness
    set style data pm3d
    set pm3d
    set contour
    a=1 #rosenbrock parameter
    b=1 #rosenbrock parameter

#set isosamples 50 splot (a-x) * (a-x) + b * (y-x*x) * (y-x*x) # 2d rosenbrock unset view unset pm3d plot 'data.dat' pt 5, 'data.dat' using 1:2:($0+1) with labels offset 1 notitle

1 个答案:

答案 0 :(得分:0)

用多色图混合2d和表面图通常是一团糟。我想你可能在这个简单的例子中不需要多重时乐。也许这样的事情就足够了:

set size square
xr=20
yr=20
set xrange [-xr:xr]
set yrange [-yr:yr]
unset key 
unset colorbox 
set surface
set pm3d map
set contour
set cntrparam levels 10# contour tenderness

rosenbrock(x,y,a,b)= (a-x) * (a-x) + b * (y-x*x) * (y-x*x)

splot rosenbrock(x,y,1,1) w pm3d, 'data.dat' u 1:2:0 w p pt 5, 'data.dat' using 1:2:(1):($0+1) with labels offset 1,1 notitle