Plot contours from one graph into another in Gnuplot - gnuplot

I have a data file with four columns X Y Z1 Z2 and I want to create a seperate color plot for each Z but plot contour lines from the first one also into the second one.
First I create a plot for Z1 and the contour file with
set terminal "pdfcairo" enhanced dashed size 5,5
set output "Output1.pdf"
set pm3d
unset surface
set view map
set contour
set cntrparam levels discrete 1.45,1.50
set table 'DATAFILE.contourZ1'
splot 'DATAFILE' using 1:2:3 notitle with lines
unset table
splot 'DATAFILE' using 1:2:3 notitle with lines
unset output
This gives me the color plot with two contour lines along Z1=1.45 and 1.50. So far so good. To load the contours into the second plot I tried
splot 'DATAFILE' using 1:2:4 notitle with lines,\
'DATAFILE.contourZ1' using 1:2:3 notitle with lines
but this only gives me the colorplot for Z2 without any contour lines.
Does anyone know, how I can accomplish this? If it's not possible in such an easy way as I have tried, I'm open for other ways, too :)
Thank you very much!

You have to unset pm3d before saving the table file so that you get a file with only the contour-line points.
Then if you want to plot pm3d and lines you might want to use set pm3d explicit and a splot "contour.txt" with lines, "data" with pm3d.

Related

Gnuplot contour plot without dots

I am trying to plot a contour plot with labels with the following code.
reset
set terminal qt
set pm3d map
set contour base
set cntrparam levels incremental 0, 10, 100
set cntrlabel onecolor
set palette rgbformulae 33,13,10
# No key appears
# splot 'temperature.dat' with pm3d title "Heated 2D plate"
# Key appears
splot 'temperature.dat' with pm3d, \
'temperature.dat' with labels title "Heated 2D plate"
The outputs are shown below:
No labels (first splot command) and without key
With labels and key (2nd splot command), but with dots.
My questions:
Why is the key not appearing in the first splot command?
How to remove the dots when plotting with labels (2nd splot command)?
Will attach the data file if required.
key
The key for the "with pm3d" plot is probably covered by the pm3d surface. You can move it to the front and make it distinct from the surface coloring using set key box opaque. This will label the contours in the key as well as on the plot. To remove the redundant contour labels in the key
set pm3d explicit
set key box opaque
splot 'temperature.dat' with pm3d notitle,\
'temperature.dat' with labels title "Heated 2D plate"
dots
I am not sure why the dots appear. I do not see them when I try to reproduce the plot. Try set pm3d noborder

Gnuplot-Circular 2D Heatmap

I have to plot the temperature map of a cross-section inside a cylinder for which I use this data. When I plot the data as a heat map in Gnuplot all I get is the following figure. My heat map is supposed to be a quarter-circle. The coordinates in my data file correspond only to a quarter circle. But Gnuplot gives me a square. How do I get a quarter-circle heat map?
MWE
set pm3d map interpolate 0,0
set dgrid3d
splot 'Temp.dat' using 1:2:3
dgrid3d can only make a rectangular grid, but that is not the main problem: The default algorithm of "dgrid3d" severely distorts your data. Use "splines" (or "qnorm" ?).
You have to do this in two steps:
set dgrid3d splines
set table $dat
splot dataf
unset table
unset dgrid3d
The interpolated grid is saved in the datablock $dat. You can now plot it with pm3d, and disable any point which is outside of your original dataset.
set pm3d map ....
splot $dat using 1:2:(($1**2+$2**2) > 16) ? 1/0 : $3)
(This needs gnuplot > 5.0. If you still have an older version, you have to use a temporary file instead of $dat.)

GNUPLOT contour over splot with pm3d from different data files

i am struggling in trying to splot a nonuniform binary matrix from a datafile1, and plot over it a contour of another variable, over the same grid but another datafile. Both the datafiles are in binary matrix shape.
# CONTOUR SETTINGS
set contour surface
set cntrparam level discrete 0.3,0.067
# PRINT CONTOUR ON TABLE
set table 'tablefile_contour'
splot 'contour_variable_field_binary' binary with l lt -1
unset table
# FIELD SPLOT
set view map;
splot 'field_to_be_plotted_2D_binary' binary with pm3d,\
'tablefile_contour' u 1:2:3 w p lt -1
basically i have been trying to follow some recipes fished along the internet.
If I try to plot only the splot, i obtain a 2D pic. I want to put on it isolines from the 'contour_variable_field_binary' file, so i splot it on a table file and i splot it together with the field to be plotted. I do it, i obtain a black pic.
How can i superimpose isolines from another file? Any clues?
Since my suggestion is a bit too long for a comment:
Have you tried plotting both original files together? You can disable contouring of the first file using nocontour, and disable the surface for the second plot with nosurface:
set contour base
set cntrparam level discrete 0.3,0.067
set pm3d map
splot 'field_to_be_plotted_2D_binary' binary with pm3d nocontour,\
'contour_variable_field_binary' binary with l lt nosurface
Can't tell if this works properly because I have not data for testing.

Change color of dgrid3d surface in Gnuplot

Is there a way to change the color of the lines of the surface when using dgrid3d? It seem simple enough but everything I've looked at only speaks of coloring the whole surface using pm3d. I have multiple surfaces on one plot and would like to be able to specify the color of each. For example, one would be red, another would be blue, another would be black, another would be green.
If you have your data available in a file Data.dat then give this a try:
set dgrid3d 10,10
set style data lines
set pm3d
splot "Data.dat" pal
The dgrid3d tells gnuplot how many entries there are in the x- and
y-direction (those are the two comma separated parameters)
The style data lines lets gnuplot plot the result with lines
instead of points
The pm3d fills the surface with a color (if you leave this away you
will just see the lines)
pal makes the lines appear in the color of the specified value
There are much more options you can set, but i find those the most relevant.
Seems like.
set dgrid3d
splot "file.dat" with lines linecolor 4
Where 4 is color you need.
For multiple surfaces you can try
set dgrid3d splines
set table "surface1.dat"
splot "file1.dat"
unset table
unset dgrid3d
for every surface you need.
And after all surface description
splot "surface1.dat" with lines linecolor 4, splot "surface2.dat" with lines linecolor 7 ...

Gnuplot: Mix dgrid3d and point mode

I'm doing a 3d plot of values, and comparing them all against one single point. I'd like to have this single point clearly labelled in the graphs. Everything I've tried creates a plane that intersects this point due to dgrid3d I believe.
I think I can do this by overlapping two plots, but I feel like there must be an easier way.
Here is my script:
reset
set dgrid3d 10,10,10
set hidden3d
unset key
set xrange [0:550]
set yrange [0:550]
splot 'CAPS_data.dat' using 2:1:3 with linespoints
If you're comparing with only a few static points, you can add points via a labels:
set label 1 "" at X,Y,Z point
Otherwise, as you state, dgrid3d will turn that single point into a surface. The workaround for this sort of thing is to use a table and the plot your dgrid3d surface into the table. Then you can turn dgrid3d off and plot the surface with a different plotting style (e.g. pm3d).
set table "grid_data.dat"
set dgrid3d 100,100
splot "datafile.dat" u 1:2:3
unset table
unset dgrid3d
set term <whatever>
set output <whatever>
splot 'grid_data.dat' u 1:2:3 w pm3d,\
'point_data.dat' u 1:2:3 w points

Resources