gnuplot pm3d - Font size control for axis in multiplots - gnuplot

I posted a question previously about plotting multiple 3D surfaces together as a multiplot. I got the solution for that but now I am having issue with controlling the fonts of the graphs.
The fonts are terrible in multiplot and My settings are not doing anything with them
I don't know how to control these fonts. I tried ztics but it does not change anything
Here is my code:
set terminal png size 2000,1600 enhanced transparent
set encoding utf8 #iso_8859_1
set output 'output.png'
set border linewidth 2
set pm3d border lw 2
####Set the Axis and Axis-Labels Formatting####
set format '%g'
set xtics font "Helvetica,26" scale 3 # Font for xtics
set xtics offset 3,-1.5 # Put xtics away from the axis
set ytics font "Helvetica,26" scale 3
set ytics offset 3,0 # Put ytics away from the axis
set ztics font "Helvetica,26" scale 3
set ztics 5 # Difference between numbers on Y-axis
set format z "" # To hide ztics on the left side
set grid # Show gridlines on both axis
set pm3d interpolate 1,1
unset key
###---Plot the Graph###---
splot "plastoquinone-scan-a3-formatted.txt" with pm3d # For a single plot
#----------------#
# Set Multiplot #
#----------------#
#set multiplot layout 3,3
#splot "plastoquinone-scan-a1-formatted.txt" with pm3d
#splot "plastoquinone-scan-a3-formatted.txt" with pm3d,
#splot "plastoquinone-scan-b1-formatted.txt" with pm3d,
#splot "plastoquinone-scan-b2-formatted.txt" with pm3d,
#splot "plastoquinone-scan-b3-formatted.txt" with pm3d,
#splot "plastoquinone-scan-c1-formatted.txt" with pm3d,
#splot "plastoquinone-scan-c2-formatted.txt" with pm3d,
#splot "plastoquinone-scan-c3-formatted.txt" with pm3d
Please suggest how can I control the settings for fonts in multiplot and how can I control the fonts of the "key" appearing on the right side (circled red in figure).
I am unable to insert the links of the input files due to less reputation :(
Thanks for your help.

Related

Multiplot in GNU Plot with pm3d

I have an issue with multiplot in pm3d. I have a script which plots one surface but when I set multiplot, it says xrange is out of range:
Here is my code:
set terminal png size 2000,1600 enhanced transparent
set encoding utf8 #iso_8859_1
set output 'output.png'
#---------------#
# Canvas style #
#---------------#
set border linewidth 2
set pm3d border lw 2
#-------------------------------------------#
# Set the Axis and Axis-Labels Formatting #
#-------------------------------------------#
### Set xtics below ###
set xtics font "Helvetica,26" scale 3 # Font for xtics
set xtics offset 3,-1.5 # Put xtics away from the axis
### Set ytics below ###
set ytics font "Helvetica,26" scale 3
set ytics offset 3,0 # Put ytics away from the axis
### Set ztics below ###
set ztics font "Helvetica,26" scale 3
set ztics 5 # Difference between numbers on Y-axis
set format z "" # To hide ztics on the left side
set grid # Show gridlines on both axis
set pm3d interpolate 3,3 # Lines on points. Smoothness of the points
unset key # Show no key
#------------------#
# Plot the Graph #
#------------------#
splot "plastoquinone-scan-a1-formatted.txt" with pm3d
#----------------#
# Set Multiplot #
#----------------#
#set multiplot layout 2,2
#plot "++" "plastoquinone-scan-a1-formatted.txt" with pm3d
#plot "++" "plastoquinone-scan-a2-formatted.txt" with pm3d
The data files are quite long so I uploaded them on github.
Here are the links please:
https://github.com/i4hashmi/Scans/blob/master/plastoquinone-scan-a1-formatted.txt
https://github.com/i4hashmi/Scans/blob/master/plastoquinone-scan-a2-formatted.txt
I need these graphs for my PhD thesis. Help will be appreciated a lot.
Thanks

gnuplot - color some tics or axis numbers in different color

I'm using gnuplot to generate some plots with an x axis ranging from 0 to 20. Is it possible to set the color of some tics or axis numbers to a different color from the standard black?
I only found a way to change the color of the all the numbers in the x axis red with set xtics textcolor rgb "red".
What I need is to be able to change the color of the tic or number at x=0,3,6,... to red and all the others should stay black. Is this possible with gnuplot?
The color of the tic marks is set by the border color, so one can do something like this:
reset
set multiplot
set xrange [-5:5]
set xtics -5,1,0 # these tic marks will show up in black (the default border color)
set yrange [] writeback # save auto-generated y range for later
plot sin(x)
set border 0 linecolor "red" # change border color, and turn off drawing of the border
set xtics 1,1,5 textcolor "blue" # these tic marks will show up in the new border color, and we can specify the color of the labels
unset ytics # we don't want to display the y tics again
set yrange restore # use same range for y axis as before
unset key
plot NaN
unset multiplot
This solution also uses multiplot, but uses the second plot only to draw tic marks and labels whose color is different from the default black. It is important that the two plots have the same ranges and margins.
This might be cheating a bit, just create the plot twice with different xtics command on top of each other:
set xrange [0:10]
set multiplot
set size 1,1
set origin 0,0
set xtics 1 textcolor rgbcolor "green"
plot sin(x)
set size 1,1
set origin 0,0
set xtics 1, 2 textcolor rgbcolor "red"
plot sin(x)
unset multiplot
seems to work for me (gnuplot: Version 5.2 patchlevel 2 last modified 2017-11-15)

Adjusting position of individual plots in gnuplot multiplot

I am using multiplot to plot four graphs. My code is given below
set term postscript eps enhanced color
set pm3d map
set pm3d corners2color c1
set size square
set out 'defect2.eps'
unset colorbox
set colorbox horiz user origin 0.1,0.7 size 0.8,0.02
set cbrange [-1.6:0]
set xtics 25
set ytics 25
set lmargin at screen 0.1
set rmargin at screen 0.9
set multiplot layout 1,4
set xlabel "i" font "Times-italic,20"
set ylabel "j" font "Times-italic,20"
spl 'defect.dat' notitle
unset ylabel
spl 'defect_2.dat' notitle
spl 'defect_3.dat' notitle
spl 'defect_4.dat' notitle
unset multiplot
set out
This produces a following plot
However, individual plots in the picture are not properly placed. I cannot see ylabel for the first plot as it is hidden behind the screen whereas there are large blank gaps between those plots. Is there any way to reduce these gaps, increase size of these plots and show the labels properly?
Thanks in advance.
The Problem is your margin setting. The margin defines the size of the white stripe between the box containing the plot and the border of the window.
This means, tic and axis labels are printet on the Martin area! And your 10% of window width is not enough, so the labels are clipped.
So you can adjust the margins to shift all plots more to the left or adjust label font sites and offsets (Miguel's comment).

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.

Only 1 y label in GNUplot multiplot

I use gnu plot to draw a multiplot and in my script I set the y label like that:
set ylabel "foobar"
Now every plot in the multiplot has a dedicated y label on their y axis. However, I would like to have only one y label for all the plots in the multiplot and center that label also on the common y axis. How can I do that? The multiplot layout I use is a 7.1 So all the plots have the same y axis.
The simplest way is to make the first plot, then turn off the y label:
set ylabel 'foo'
set multiplot
plot 'data1.dat'
unset ylabel
plot 'data2.dat'
plot ...
unset multiplot
This will make the x-dimension of the first plot different from that of all the other plots, so you may have to play with the margins if you want all the plots the exact same size.
Plot the individual panels of reduced size without labels but with border, tics and title, then define a full-sized panel with labels but without border, tics and title.You may have to plot a dummy function (1/0).
Global label workaround
This is not ideal, but if you desperate like me, you can use a rotated global label + larger left margins:
#!/usr/bin/env gnuplot
label_label_size = 14
set terminal png
set output "gnuplot.png"
set multiplot layout 2,1 title "Multiplot with one ylabel" font ",18"
set lmargin 10
set label "My y-label" at screen 0.05,0.5 center front rotate \
font "," . label_label_size
plot sin(x)
set xlabel 'My x-label' font "," . label_label_size
plot cos(x)
Here is a realistic application that motivated me to do this: Heap vs Binary Search Tree (BST)
Tested in gnuplot 5.2 patchlevel 6, Ubuntu 19.04.
This is basically the suggestion from Fabian Claremont's answer, but (for beginners) put into code and visualized. Actually, Ciro Santilli's solution is even shorter.
Tested with gnuplot 5.2. For gnuplot 4.6 (the time of OP's question), replace reset session with reset and set margin 8,-1,1-1 with set lmargin 8 and set bmargin 1.
Code:
### Multiplot with single y-label
reset session
unset key
set sample 500
set multiplot layout 7,1
unset ylabel
set linetype 1 lc rgb "red"
set margins 8,-1,1,-1 # left, right, bottom, top (-1=auto)
set ytic 1.0
set title "Plot 1" offset 0,-1
plot sin(1*x)
set title "Plot 2" offset 0,-1
plot sin(2*x)
set title "Plot 3" offset 0,-1
plot sin(3*x)
set title "Plot 4" offset 0,-1
plot sin(4*x)
set title "Plot 5" offset 0,-1
plot sin(5*x)
set title "Plot 6" offset 0,-1
plot sin(6*x)
set title "Plot 7" offset 0,-1
plot sin(7*x)
set lmargin -1 # automatic lmargin
unset title
set origin 0,0
set size 1,1
set border 0
unset tics
set ylabel "This is a centered y-label"
plot [][0:1] -1 # plot a dummy line out of range
unset multiplot
### end of code
Result:

Resources