Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gnuplot: plotting with image, how to add a contour

Tags:

gnuplot

I have the following scenario: I plot data using with image to plot a map of intensity levels. They are already binned. Now I am looking for a way to plot the same data such that I can get a contour plot. I want to this so that I can use this plot as an overlay over another plot so that people see the intensity levels there.

I know it would be possible with using lines, but then I would have to create the lines from data first while identifying the borders of each intensity level. I hope there is a more straight forward way to achieve this with gnuplot.

To visualize what I want to achieve here an example plot using with image:

intensity plot

And for this I would like to get contours like shown here.

The data is in the following format:

0 0 36
0 1 36
0 2 36
0 3 36
0 4 36

with each line containing: XCoord YCoord IntensityLevel

What I want to achieve is to have a plot from the same data which gives me contour lines for the intensity level (such that I could also decide to make contours stretch of two or more intensity levels). Is there a way t achieve this without generating new data?

like image 896
Sjoerd222888 Avatar asked Mar 14 '15 14:03

Sjoerd222888


1 Answers

You can do this using a table to generate the contours with splot. Something along these lines:

set contour
unset surface
set cntrparam levels auto 20 # Modify this to your liking
# I'm not sure this is actually needed
set view map
unset clabel
#
set table "contours.dat"
splot "data.dat" u 1:2:3 not
unset table
unset contour

plot "data.dat" u 1:2:3 w image not, "contours.dat" u 1:2 lc 0 w l not

I put lots of contours (20) so you can see the effects. For contour options, try help set cntrparam.

enter image description here

Another possibility is to use directly splot ... with pm3d instead of plot ... with image, but this could be undesirable if you use a vector-based terminal because of the file sizes.

like image 123
Miguel Avatar answered Nov 03 '22 16:11

Miguel