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.
Related
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
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.)
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.
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
I'm trying to plot two data sets with gnuplot. They are both (x, y, z) triplets. They are not arranged on a grid. I want to plot one of them using dgrid3d and pm3d. On top of that I want to overlay the other data set but as just scattered points.
To give a more concrete example: I am trying to plot the effect of a cylinder approaching a surface. I want to plot the response of the surface and that's where dgrid3d comes in handy. On top of that, I want to plot the position of the cylinder and I have its circumference as points.
I used:
set dgrid3d 100,100,4
set pm3d
splot "dataset1" with pm3d, "dataset2" with dots
The data set has about 100x100 points, arranged on a near-square, so 100,100 works best here. No matter how I plot the second data set, it always ends up being a square of the same dimensions as the cylinder, instead of a nice circle. When I turn dgrid3d off, I can plot the second data set on its own and the result is a nice circumference of the cylinder.
So my question is: is it possible to plot a 3D graph using two data sets, one using dgrid3d and the other one not using it?
Yes, this is possible, but it is a little more tricky than you might think. The key is to use set table
For your example:
set dgrid3d 100,100,4
set pm3d explicit
set table "interpolated_data.dat"
splot "dataset1" with pm3d #writes the interpolated data to "interpolated_data.dat"
unset table
unset dgrid3d
splot "interpolated_data.dat" with pm3d, "dataset2" with dots
The reason that your attempt didn't work is because when dgrid3d is in effect, All data read in is interpolated to a grid and then plotted using whatever style you specify.
From gnuplot's help dgrid3d
When enabled, 3D data read from a file
are always treated as a scattered data set.
As a side note, this method can also be used to plot contours on top of a pm3d as well.