i am 3d plotting a matrix with some values, and i need to add contour lines to the plot, is there a simple gnuplot command to do this?
I tried the command: "set contour base" but only 1 line came up, i think it should be many lines. See matlab picture
When i plot it in gnuplot i only get 1 contour line in the top left corner.But everything else is correct.
My goal is to get it to look like in matlab like this Matlabplot
I also found this example: see link in comments (dont have enough rep), but i dont understand where i should put in the data values from test.txt
test.txt
gnuplot commands
set view map
set yrange [0:30]
set xrange [0:30]
set dgrid3d 100,100,4
set contour base
splot 'test.txt' u 1:2:3 w pm3d
What you are missing is to tell gnuplot where to put the contours. This is done via the
set cntrparam levels incr -0.3,0.1,0.5
command which means: start at -0.3 and trace a contour every o.1 up to 0.5.AFAIK if you want to make contours all black, you have to save the contour lines in a temporary file (here
contour.txt
).So your script would be
which gives you this:
Note:
you can get rid of interpolation file (
dgrid.txt
) if you format a bit your datafile by leaving a blank line after each row (i.e. every 30 datapoints) because they are already mesh-ordered.This could be done also with a
awk
script. But I'm too lazy to look into it...The rest will remain the same and will work as expected.
here is how it should look like :
In which case the script would simply become:
with no need of ntermediate file and with better contour since data in not interpolate by gridded: