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
:
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?
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
.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With