Reputation: 1972
I'm trying to create a colormap plot of datasetA with a contour plot of datasetB, both of which are read in from files.
The following successfully creates a colormap of datasetA:
plot 'valuesA.dat' matrix with image
I can draw contours as described here.
How can I combine the two plots?
Thanks in advance!
Upvotes: 2
Views: 3232
Reputation: 1972
Here's how I ended up doing it for an array of size 512x512 (for example). Suppose I have a datafile A.dat
which is to be used for the colormap and B.dat
for the contours.
B.dat
containing the contour data and save it to a temporary file temp.dat
.A.dat
and plot the contour lines from the temp file temp.dat
in a single command. Here's my code (simplified somewhat for clarity):
# Set initial state
reset
set term X11
set palette @MATLAB # see http://www.gnuplotting.org/matlab-colorbar-with-gnuplot/
# Create a file for contour data
set contour base
set cntrparam levels 25
set isosample 250,250
unset surface
set table "temp.dat"
splot "B.dat" binary array=512x512 format='%double'
unset table
# Plot the final results
set title "Contours and Colormap"
set size square
unset key
set xtics ('0' 0, '0.5' 255, '1.0' 511) # Change these according to your dimensions
set ytics ('0' 0, '0.5' 255, '1.0' 511) # Change these according to your dimensions
set cbrange [0.0:1.0]
set xlabel "X (scaled by height)"
set ylabel "Z (scaled by height)"
set terminal png
set output "output.png"
plot "A.dat" binary array=512x512 format='%double' with image, "temp.dat" with lines lt -1
To see what it looks like, I ended up using a scripted version of that code to produce this movie (and others) for my research!
Upvotes: 1