Gnuplot-Plotting only colorbox - gnuplot

I am plotting several heatmaps using Gnuplot. However, I am not not using group plot in Gnuplot as I have decided to do this better in Latex with individual heatmaps obtained. What I need now from Gnuplot is a plot/figure with only colorbox (nothing but colorbox). Is there any way to do it in Gnuplot?

Eg. if your heatmaps are from 5-12:
unset key
set view map
set style data pm3d
set style function pm3d
set xtics norangelimit 1
unset ytics
unset ztics
set title "Colorbox for heatmaps"
set xrange [ 5.0000 : 12.0000 ] noreverse nowriteback
unset colorbox
splot (x-5)/(12-5)
OR if you want it to be vertical:
set size ratio 3
unset key
set view map
set style data pm3d
set style function pm3d
unset xtics
set ytics norangelimit 1
unset ztics
set title "Colorbox for heatmaps"
set yrange [ 5.0000 : 12.0000 ] noreverse nowriteback
unset colorbox
splot (y-5)/(12-5)

Related

Smoothening plot in gnuplot with pm3d

When plotting an X,Y,Z data set as color map I need to smoothen the plot a bit. The data are sparse and I need some sort of gaussian blur applied to the result.
Using following code :
reset
#set zrange [2:6]
set contour
unset surface
set cntrparam levels incr 2.0,0.5,8.0
set view map
set xrange [0:2184]
set yrange [0:1472]
set dgrid3d 100,100,4
set table "ap130_base_contour.txt"
splot 'ap130_base.dat' using 11:12:14
unset table
unset contour
set surface
set table "ap130_base_dgrid.txt"
splot 'ap130_base.dat' using 11:12:14
unset table
reset
set pm3d map
unset key
set palette defined (0 '#352a87', 1 '#0363e1',2 '#1485d4', 3 '#06a7c6', 4 '#38b99e', 5 '#92bf73', 6 '#d9ba56', 7 '#fcce2e', 8 '#f9fb0e')
set autoscale fix
set grid
set terminal png size 2184,1472 enhanced font "Helvetica,20"
set output 'ap130_base.png'
splot 'ap130_base_dgrid.txt' w pm3d, 'ap130_base_contour.txt' w l lc rgb "black"
set output
set terminal X11
The plot looks like this;
Is there a way to make this less 'spotty'?
Your input is much appreciated.
Gert.

Forcing same palette on multiple pm3d plots in gnuplot

Following the great info on splot pm3d I want to create two color / contour plots with same color range.
Below code creates two plots. The way the data comes in the first data set has z-data 2.0 to 5.5. The second 1.5 to 5.5. I would like both plots to use and show the same color key scale for both for better comparison. (i.e. 2 to 6)
I tried using zrange but it did not work.
#- BASE ---------------------------------------------
reset
#set zrange [2:6]
set contour
unset surface
set cntrparam levels incr 2.0,0.5,8.0
set view map
set xrange [0:2184]
set yrange [0:1472]
set dgrid3d 100,100,4
set table "ap130_base_contour.txt"
splot 'ap130_base.dat' using 11:12:14
unset table
unset contour
set surface
set table "ap130_base_dgrid.txt"
splot 'ap130_base.dat' using 11:12:14
unset table
reset
set pm3d map
unset key
set palette defined (0 '#352a87', 1 '#0363e1',2 '#1485d4', 3 '#06a7c6', 4 '#38b99e', 5 '#92bf73', 6 '#d9ba56', 7 '#fcce2e', 8 '#f9fb0e')
set autoscale fix
set grid
set terminal png size 2184,1472 enhanced font "Helvetica,20"
set output 'ap130_base.png'
splot 'ap130_base_dgrid.txt' w pm3d, 'ap130_base_contour.txt' w l lc rgb "black"
set output
set terminal X11
#- TSFF ---------------------------------------------
reset
#set zrange [2:6]
set contour
unset surface
set cntrparam levels incr 2.0,0.5,8.0
set view map
set xrange [0:2184]
set yrange [0:1472]
set dgrid3d 100,100,4
set table "ap130_tsff_contour.txt"
splot 'ap130_tsff.dat' using 11:12:14
unset table
unset contour
set surface
set table "ap130_tsff_dgrid.txt"
splot 'ap130_tsff.dat' using 11:12:14
unset table
reset
set pm3d map
unset key
set palette defined (0 '#352a87', 1 '#0363e1',2 '#1485d4', 3 '#06a7c6', 4 '#38b99e', 5 '#92bf73', 6 '#d9ba56', 7 '#fcce2e', 8 '#f9fb0e')
set autoscale fix
set grid
set terminal png size 2184,1472 enhanced font "Helvetica,20"
set output 'ap130_tsff.png'
splot 'ap130_tsff_dgrid.txt' w pm3d, 'ap130_tsff_contour.txt' w l lc rgb "black"
set output
set terminal X11
Note the color scale i the first plot from 2.0 to 5.5
In the second plot from 1.5 to 5.5
I would like both plots to have a color scale from i.e. 1 to 6.
Your input is appreciated.
Gert
Try
set zrange[2:6]
set cbrange[2:6]
It should do the trick.

Smooth gradient display of function of two (xy) variables in gnuplot?

I'd like to show the values of a function of 2 variables, say x+y, as a "bitmap" image. So I tried this, based on http://gnuplot.sourceforge.net/demo/heatmaps.html:
# Color runs from white to green
set palette rgbformula -7,2,-7
set cbrange [-5:5]
set cblabel "Value"
unset cbtics
set xrange [-4.5:4.5]
set yrange [-4.5:4.5]
set view map
splot x+y with image
... but I get nothing:
$ gnuplot -persist test.gp
"test.gp", line 45: warning: Image grid must be at least 2 x 2.
So how can I get the "pixel" at, say, x=-2, y=-2 to be colored according to x+y=-4 on the cbrange?
Edit: got that:
set palette rgbformula -7,2,-7
set cbrange [-5:5]
set cblabel "Value"
unset cbtics
set xrange [-4.5:4.5]
set yrange [-4.5:4.5]
set pm3d
unset surface
set view map
splot x+y
Outputs:
But - say I want the gradient in this range, exported as "smooth" gradient (no axes, ticks, marks of any kind) on a big PNG, say 3000x2000 pixels; what would be the best way to achieve that?
Starting from your edit: You just to deactivate every thing. Meaning:
unset colorbox
unset xtics
unset ytics
set border 0
Then id you create the command list:
set palette rgbformula -7,2,-7
set cbrange [-5:5]
unset cblabel
unset cbtics
set xrange [-4.5:4.5]
set yrange [-4.5:4.5]
set pm3d
unset surface
set view map
unset colorbox
unset xtics
unset ytics
set border 0
splot x+y
You get only the gradient
EDIT: In order to improve the gradient step and create a smoother image you need to use pm3d's interpolate.
set pm3d interpolate 4,4

Gnuplot: Hidden3D

Is there a way I can hide these overlayed lines in the back of my plot? I tried to use the hidden3d option, but it doesn't work as I expected.
set encoding utf8
set key right top
set xrange[0:1]
set yrange[0:1]
set grid
set ztics 0.01
set palette rgbformulae -5,-12,-30
set xlabel "x" font "Helvetica, 20"
set ylabel "y" font "Helvetica, 20"
set zlabel "z" font "Helvetica, 20"
set terminal postscript eps enhanced color font "Helvetica, 20"
set output "approx_jacobi.eps"
ue(x,y) = sin(pi*x)*sin(pi*y)/(2*pi**2);
#set hidden3d front
set dgrid3d 31, 31 qnorm 2
splot 'results.dat' with pm3d notitle,\
ue(x,y) w l lw 2 t 'Exact'
The result I'm currently getting is
Using set hidden3d front works fine for me. I had to increase the isosamples a bit to avoid intersections of the lines with the surface due to the linear interpolation. Also you don't need to use set dgrid3d since you already have a regular grid.
set pm3d
set hidden3d front
set ticslevel 0
set isosamples 40
set palette rgbformulae -5,-12,-30
ue(x,y) = sin(pi*x)*sin(pi*y)/(2*pi**2)
splot 'results.dat' with pm3d, ue(x,y) w l
The result with 4.6.5 is:

How to fix GNUPLOT replot issue

I set-up a multiplot like this:
set terminal wxt size 1500,900
set format x "%d%m%y %H:%M:%S"
set xdata time
set timefmt x "%Y%m%dT%H%M%S"
set key font ",6"
set lmargin 10
set rmargin 10
set multiplot layout 2,1
plot "output.txt" u 1:2 w lines axes x1y1, \
"output.txt" u 1:3 w lines axes x1y2
plot "output.txt" u 1:40 w lines axes x1y1, \
"output.txt" u 1:39 w lines axes x1y2
set y2tics border
unset multiplot
Which works, and gives me 2 plots, one above the other.
But pressing the "replot" button (or using zoom) causes the second plot to fill the window - completely hiding the first plot.
Yes, that's how replot behaves. The documentation says: „Note that in multiplot mode, replot can only reproduce the most recent component plot, not the full set.“.
So, what you can do is to put the whole set multiplot ... unset multiplot stuff in an external file, load it, and then load it again. Or put that stuff in a string and eval it several times.
I had the same issue. Solved it with a loop:
set term wxt enh
do for [IDX = 0:1] {
if (IDX==1) {
set terminal png enhanced
set output 'temp.png'
}
set multiplot
set size 1,1
set origin 0,0
plot sin(x)
set size 0.5,0.35
set origin 0.13,0.63
plot cos(x)
unset multiplot
}
set output
set term wxt enh
Here is another workaround. It does not answer the question directly, but it could give idea to other similar issues. Put header, and a footer 'reread', then two context could be choosen for a similar multiplot (done twice)
if (exists("rehearse")) rehearse=1+rehearse; set term x11
if (!exists("rehearse")) rehearse=0; set term png; set output sprintf("test_palette_%s.png", system("date +\"%F\""))
pr "rehearse=".rehearse; show term #<= comment printing
set samples 100; set isosample 100,100
set xrange [0:1]; set yrange [0:1]
set palette defined (0 "white", 1 "red")
set autoscale cbfix; unset colorbox; unset key
set multiplot layout 2,2
plot '++' using 1:2:1 with image
plot '++' using 1:2:2 with image
plot '++' using 1:2:(-$1) with image
plot '++' using 1:2:(-$2) with image
unset multiplot
if(rehearse < 1) reread

Resources