Search code examples
plotgnuplotsurface

gnuplot adding vector fields on top on contour plot


I would like to add i.e., replot a vector plot on top of contour plot as shown in figure below. However when I use the following code I'm not able to see the vector, how I dont get the vector $data 0,0,2,2 when I plot using the following code.

enter image description here

set terminal wxt size 800,600 enhanced font 'Verdana,10' persist
set view map
set style fill  transparent solid 0.50 noborder
unset surf
set contour base
set cntrparam levels disc 450,250,150,100,60,30,10,2
set yrange [0:6]                                        
set xrange [0:6]                                        
set isosample 40
set style arrow 5 head noborder size screen 0.03,15,135 ls 1 lw 5
splot [x=0:5] [y=0:5] (x**2+y-11)**2+(x+y**2-7)**2 lc 4
$data << EOD                     
0 0 2 2
EOD
replot $data using 1:2:3:4 w vector

Solution

  • You use splot (3D) instead of plot (2D), so you need 3D-data instead of 2D-data for the vector. Try to replace the replot command with this:

    replot $data using 1:2:(0):3:4:(0) w vector lc -1
    

    Result: vector on top of contour

    It should also work to add two columns to the $data and plot with ... using 1:2:3:4:5:6 ..., I have not tried that.

    (gnuplot 5.0)