gnuplot: plotting with image, how to add a contour

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?

1 Answer

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.

4

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like