How to improve lines quality of a heat map - gnuplot

I have plotted the matrix of numbers of this file
pher-of-1365.txt
with this code
set encoding iso_8859_1
set term postscript eps enhanced color size 4.7in,4in
set xlabel "longitude"
set ylabel "latitude"
set output "test0.eps"
set size square
set title "Pheromones" font "Helvetica, 16"
set autoscale fix
set key
set yrange [:] reverse
set view map
splot 'pher-of-1365.txt' matrix with image
Which produces this plot:
The quality is not bad but the lines look blurred.
Is there a way to improve the clarity of the lines in the image?
Regards

Use can try to use a different plot statement, and tweak the point size to get a sharper image. I used your script with the pdf terminal, in 4 different cases:
set terminal pdf size 12,12
set output "test0.pdf"
set encoding iso_8859_1
set xlabel "longitude"
set ylabel "latitude"
set size square
set format cb "%2.0t{/Symbol \327}10^{%L}"
set autoscale fix
unset key
set yrange [:] reverse
set view map
set multiplot layout 2,2
set title "plot with image"
splot 'pher-of-1365.txt' matrix with image
set title "plot with points pointtype 5 pointsize 0.45 palette"
splot 'pher-of-1365.txt' matrix with points pointtype 5 pointsize 0.45 palette
set title "plot with points pointtype 5 pointsize 0.25 palette"
splot 'pher-of-1365.txt' matrix with points pointtype 5 pointsize 0.25 palette
set title "plot with points pointtype 3 pointsize 1.25 palette"
splot 'pher-of-1365.txt' matrix with points pointtype 3 pointsize 1.25 palette
Resulting in:
Things to note:
The only reason the solution on the upper right panel works is because your plotting area is squared, and I used pointtype 5 (filled squares). Then, be tweaking the pointsize param you can fill the entire area. Note what happens on the bottom panels, when I change the size and type on the points.
As mentioned in the comments, the right way of doing this is using image, since it will figure things our by itself, and fill in the plotting area.

Related

How to move and manage overlapping of x ticks with axis in Gnuplot

I am trying to plot an inlet graph which is shown in Figure. Being an inlet graph it is needed to show x tics and y ticks of relatively big sizes for clear visibility. But when I increase the fonts as,
set xtics font ", 40"
tics overlaps with axis. I increased the plot size set term png size 1000, 1000 but still the issue persists. Kindly suggest if there is a way to move the tics below or to a desired position in graph.
Edit:
The gnuplot script looks like this,
set term png size 1000, 1000
set output "b_vs_N.png"
set style fill solid
set style circle radius 0.001
FIT_LIMIT=1.e-14
set yrange [0.15:0.25]
set style fill solid
set style circle radius 0.001
set xtics 10
set ytics 0.03
set border 15 back lw 6
set xtics font ", 40"
set ytics font ", 22"
set ylabel "b" enhanced font "1 {,40}"
set xlabel "N_i" font "1 {,40}"
set lmargin 12
set bmargin 4
set palette model HSV
set palette rgb 3,2,2
set palette maxcolors 12
set view map
AA(x)=a+b*x+c*x**2
fit AA(x) "data.txt" using 1:2 via c, b, a
plot "data.txt" using 1:2 lt 1 pt 11 ps 2.0 lc rgb "black" notitle, AA(x) w lines lw 2 lc rgb "sienna1" notitle
Your example is uncomplete without code and therefore difficult to reproduce. Please check help xtics. There is the option offset.
Maybe the following example helps to solve your issue.
In the example below no special offset seems to be necessary, i.e. offset 0,0, but you can shift and adjust the labels in x and y direction.
Code:
### tic label offset
reset session
set multiplot
plot sin(x)/x
set origin 0.07, 0.6
set size 0.3,0.3
set xrange [0:10]
set xtics 5 out font ",20" offset 0,0
plot x**2
unset multiplot
### end of code
Result:

Add guiding lines over pm3d map in Gnuplot

I'm trying to add some guiding lines over a pm3d map using Gnuplot.
Below is the code I use to plot pm3d map (my pm3d map).
set terminal post eps enhanced color solid "Helvetica" 16
set encoding iso_8859_1
set hidden3d
set pm3d map
set view map
unset surface
set size square
splot "map.ene" with image
set xlabel "RC1 ({\305})"
set ylabel "RC2 ({\305})"
set cblabel "{/Symbol D}G (kcal/mol)" offset 1,0,0
set xrange ["1":"11"]
set yrange ["5.5":"9.5"]
set cbrange ["-3.1":"0.0"]
set xtics 1
set ytics 1
set cbtics 1
set mxtics 2
set mytics 5
unset key
set palette defined (-3.1 "red", -2.5 "yellow", -1.5 "green", -0.5 "blue", 0 "white")
unset colorbox
set output "map.eps"
replot
map.ene is in the format below:
1.000 5.500 0.00000 i
Now I want to add a vertical line (x=5.5) over the pm3d figure. I searched old posts and found similar questions already been asked by others. Seems there are two possible solutions:
1) prepare a separate data file for the line (x.dat, 5.5,y,0.0) then use command below to plot.
splot "map.ene" with pm3d, "x.dat" using 1:2:(0.0) with points linecolor rgb "black"
2) use "multiplot" facility in Gnuplot.
I tried both, neither worked. I've been playing this for a while but sill not sure how I should modify my original pm3d code to add guiding lines.
you can draw lines in gnuplot:
set arrow from first 5.5, graph 0 to first 5.5, graph 1 nohead
type help coordinates to better tune the above command.

Gnuplot color gradients

I need to create a number of vertical gradients in my plot - four in total, in order to clarify direction (N,E,S,W).
#set 0 to 45 degrees color
set obj 1 rectangle behind from screen 0.09,0.2 to screen 0.89,0.29
set palette model RGB defined ( 0 "white", 1 "red")
set cbrange[0:1]
unset colorbox
Am I missing something here?
Thanks in advance
You cannot fill a rectangle with a gradient. The palette affects only plotted functions or data sets. You can either use the image or pm3d plotting style to do this.
One example:
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
The output with the pngcairo terminal and version 4.6.5 is:
Now you must find a way to integrate this with the other plots you have.

how to change gnuplot's graph size

I am trying to plot a graph with increased font size in gnuplot. A typical example is:
p sin(x) w l lw 5
set border lw 4
set tics font "Halvetica Bold,20"
So, I am trying to have:
adjust plot size without changing the canvas size to accommodate x/y label and tics
to adjust space between tics and label
How can I achieve this?
Kindly help.
The margins and the label positions depend on the total font size. You can specify this as part of the set terminal command.
The following script gives good margins and label positions:
set terminal wxt font ",20"
set border lw 4
plot sin(x) lw 5
For your example, you could adjust the margins with set lmargin ... and similar commands, and adjust the tic offset with set xtics offset ...:
set terminal wxt
set border lw 4
set tics font "Halvetica Bold,20"
set bmargin 3
set lmargin 10
set xtic offset 0,-1
set ytics offset -0.5,0
plot sin(x) lw 5

Gnuplot, Multiplot: Mix normal and parametric plot with a single legend box?

I create overlapping graphs in Gnuplot, because I mix normal and parametric plots (and also pm3d maps and parametric surfaces). This works fine mostly, except for one thing: If both plots have a title, the legends usually overlaps. A typical example looks like this:
#legends.gp
set term pngcairo enhanced color linewidth 1.5 dashed dashlength 1.4 rounded
set output "legends.png"
set title "legends test"
set multiplot
# make a box around the legend
set key box
set border 15 lw 1
# fix the margins, this is important to ensure alignment of the plots.
set lmargin at screen 0.15
set rmargin at screen 0.98
set tmargin at screen 0.90
set bmargin at screen 0.15
set xlabel "x"
set ylabel "sin(x)"
set xrange[0:2*pi]
set yrange[-1:1]
set grid x y
# add single tic at 0.62
set xtics add ("x0" 0.62)
# main plot command
plot sin(x) title "sinus"
# turn everything off
set format x "" #numbers off
set format y ""
set xlabel "" #label off
set ylabel ""
set border 0 #border off
unset xtics #tics off
unset ytics
unset grid #grid off
unset title #title off
#plot vertical line at 0.62
set parametric
plot 0.62,t ls 2 lw 2 title "parametric Line"
unset parametric
unset multiplot
My question is now, is there a simple, mostly automatic way to create a single legend for multiple plots?
P.S. Sorry, I ended up making the example file more complex than it had to be by showing some more features, that are hopefully helpful for future readers.
Here's a VERY dirty hack that works for me. change:
plot sin(x) title "sinus"
to:
plot sin(x) title "sinus",NaN w l ls 2 lt 2 title "parametric line"
Then plot the parametric line without a title (e.g. notitle instead of title "parametric line").
This works because gnuplot ignores NaN's when plotting -- Essentially the second thing we're plotting above just adds one element to the legend. I specify the linetype, etc to be the same as your parametric plot linestyle/type so that it shows up properly in the legend. To my knowledge, this is the only way to do something like this...
Of course, you could just edit it so that both are plotted parametrically and forgo the entire multiplot buisness...
set xrange [0:2*pi]
set yrange [-1:1]
set parametric
set trange [-10:10]
plot t,sin(t) title "Hello", 0.62,t title "World"
that's probably the "cleaner" solution...(but less fun working with gnuplot "magic")
From the gnuplot info manual:
To draw a vertical line from the bottom to the top of the graph at
x=3, use:
set arrow from 3, graph 0 to 3, graph 1 nohead

Resources