Setting the size of title in gnuplot - gnuplot

I have the following script to place in a bash script:
#!/bin/bash
set -e
gnuplot -persist <<-EOFMarker
set pixmap 1 "pathToimage/fig.png" at screen 0.85, 0 width screen 0.15 behind
set rmargin at screen 0.85
# Border line definition
set border lw 1
# Major and Minor grid definition
set style line 100 lt 1 lc rgb "gray" lw 2
set style line 101 lt 0.5 lc rgb "gray" lw 1
set grid mytics ytics ls 100, ls 101
set grid mxtics xtics ls 100, ls 101
set title 'myTitle' font ", 30"
set ylabel 'y [m]' font "Helvetica, 12"
set xlabel 'x [m]' font "Helvetica, 12"
set tics font "Helvetica,10"
plot [-10:10] sin(x),atan(x),cos(atan(x))
EOFMarker
The script is intended to do some plotting and place a logo on the corner of the plot. However, I am not able to change the size of the fonts... I am using gnuplot 5.4.3.
Any advice?

Have you tried to set a terminal? Maybe your default terminal does not support changing the title size.
Using this script, I can set the title size:
set pixmap 1 "linux.png" at screen 0.85, 0 width screen 0.15 behind
set rmargin at screen 0.85
# Border line definition
set border lw 1
# Major and Minor grid definition
set style line 100 lt 1 lc rgb "gray" lw 2
set style line 101 lt 0.5 lc rgb "gray" lw 1
set grid mytics ytics ls 100, ls 101
set grid mxtics xtics ls 100, ls 101
set term png # new
set o "output.png" # new
set title 'myTitle' font ", 30"
set ylabel 'y [m]' font ", 12" # removed font spec
set xlabel 'x [m]' font ", 12" # removed font spec
set tics font ",10"
plot [-10:10] sin(x),atan(x),cos(atan(x))
set o
The output is
If I set the font size to 12, I get

Related

Shifting of axis title and sub-title in Gnuplot histogram

Mr data file is
# test.dat
# Sample No. Phenol Red Neutral Red Bromophenol Blue Bromocresol Green Mixed Indicator
1 80 69 223 222 130
2 89 62 321 267 160
3 92 67 248 276 147
Gnuplot code is
#
#
###
reset session
###
set terminal postscript eps enhanced colour font 'Times-Roman,12' size 6in,4in
set output "test.eps"
#------------------------------------------------------------------------------
set style line 1 lt 4 lw 1 lc rgb "#4169E1"
set style line 2 lt 4 lw 1 lc rgb "#2E8B57"
set style line 3 lt 5 lw 1 lc rgb "#FF4500"
set style line 4 lt 4 lw 1 lc rgb "#FAD02C"
set style line 5 lt 4 lw 1 lc rgb "#FF0080"
#------------------------------------------------------------------------------
set xtics out scale 1.5
set ytics out scale 1.5
set ytics nomirror
set yrange [0:350]
set key off
set tics font ", 16"
set xlabel "Sample No. " font ",16"
set ylabel "Moisture Content ({/Symbol \155}g of H_{2}O/g of melt)" font ",16"
set key samplen 2 spacing 1.65 font ",14" width -1.0
set key inside left horizontal
set style fill solid border
set style histogram clustered gap 1 title textcolor lt -1
# ----------------------------------------
set rmargin screen 0.9
set lmargin screen 0.1
set bmargin screen 0.4
# ----------------------------------------
set style data histogram
plot \
newhistogram "Direct titration", \
'test.dat' using 2:xtic(1) ls 4 axes x1y1 title "Phenol Red", \
'' u 3 ls 5 axes x1y1 title "Neutral Red", \
newhistogram "Back-titration", \
'test.dat.dat' using 4:xtic(1) ls 1 axes x1y1 title "Bromophenol Blue", \
'' u 5 ls 2 axes x1y1 title "Bromocresol Green", \
'' u 6 ls 3 axes x1y1 title "Mixed Indicator"
# ----------------------------------------
##
Script works fine. I would like to provide more spacing between the tick labels (1,2,3) and the sub-title (Direct titration and Back-titration) as well as spacing between the sub-titles and axis title. How can it be done?
set xlabel offset 0, -1 will shift both the subtitles and the axis title downward by one character height.
set xlabel "\nTEXT" will create a two-line axis label and place TEXT on the second line.
Modifying your xlabel command to be
set xlabel "\nSample No. " font ",16" offset 0,-1
will make both those changes.

How to manage tick lable and axis-lable in gnu multiplot

I have two files each is having five columns where 1st will be the x-axis in both the data.
I want to make a multiplot 2 2 in GNU with zero spacing.
I could manage many things but I am could not fix below problems:
1. How to place the figure at the center of the page i.e. equal left right margin? I set the left, right, top and bottom margin but it is not working.
2. How to number the figure. For example, Figure 1 1 should be numbered as (a), figure 1 2 should be numbered as (b) and so on.
3. How to put tick lable and tick mark on the plot 1 2 and 2 2 on right side of the plot?
4. how to create a common title at the bottom of the figure representing the X-axis.
I have tried to make gnu multiplot layout but still it is not giving desired results. The script I used is mentioned below:
My code is
[![set terminal postscript eps enhanced size 20cm,15cm color solid lw 3 "Times-Roman" 24
reset
set lmargin screen 0.10
set rmargin screen 0.95
set bmargin screen 0.15
set tmargin screen 0.9
set mxtics 2
set mytics 2
set tics font "Times-bold, 50"
set output "absorption.pdf"
set multiplot layout 2,2 margin 0.2, 0.9, 0.1, 0.9 spacing 0.00, 0.00
set tics scale 1.2
set tics font "Times-bold, 26"
set key spacing 1.2
unset key
set xrange \[0:8.5\]
set yrange \[0:1\]
set xlabel ' '
set format x ""
set ylabel 'A11' font 'Times-bold, 26' offset 1,1,3
unset label
plot "data1.dat" u 1:($2/10**4) w l lw 3 lt 2 lc rgb "red" title "x-D", 'data1.dat' u 1:($3/10**4) w l lw 3 lc rgb "blue" title "z-D"
unset label
unset format x
unset key
set key inside center top # to adjust the legends position
set xrange \[0:8.5\]
set yrange \[0:1\]
set title ' '
set xlabel ' '
set xlabel ' '
set format x ""
set ylabel ' '
set format y " "
set key spacing 1.2
set ylabel 'A12' font 'Times-bold, 26' offset 1,0,3
plot "data1.dat" u 1:($4/10**2) w l lw 3 lt 2 lc rgb "red" title "x-D", 'data1.dat' u 1:($5/10**2) w l lw 3 lt 2 lc rgb "blue" title "Z-D"
unset label
unset format y
unset format x
unset key
set xrange \[0:8.5\]
set yrange \[0:1.08\]
set xlabel ' '
unset label
set ylabel 'A21' font 'Times-bold, 28'
unset label
plot "data2.dat" u 1:($2/10) w l lw 3 lt 2 lc rgb "red" title "x-dir", 'data2.dat' u 1:($4/10) w l lw 3 lt 2 lc rgb "blue" title "z-dir" ,\
unset label
unset format x
unset key
set xrange \[0:8.5\]
set yrange \[0:1.08\]
set title ' '
set format y ""
set xlabel 'X-12-scale' font 'Times-bold, 28'
set ylabel 'A22' font 'Times-bold, 28'
plot "data2.dat" u 1:($3/10) w l lw 3 lt 2 lc rgb "red" title "x-dir", 'data2.dat' u 1:($5/10) w l lw 3 lt 2 lc rgb "blue" title "z-dir"
unset label
unset format y
unset key
unset multiplot
set output][1]][1]
My data should be like what I want according to attached figure queries and hand marks.
Try this
reset
set encoding utf8
set terminal pngcairo size 750,500 font ",10"
set output "Multiplot_2x2.png"
set multiplot \
layout 2,2 rowsfirst \
title "{/:Bold=11 Multiplot 2×2}" \
margins screen 0.10,0.92,0.12,0.90 \
spacing screen 0.00,0.00
set link y2
# Gaussian fuction
f(x,a,b,c) = a*exp(-((x-b)/c)**2)
# Parameters to first one
a1 = 0.95
b1 = 4.00
c1 = 1.00
# Parameters to second one
a2 = 0.95
b2 = 5.00
c2 = 1.00
# Line style
set style line 1 lc "#e41a1c" # red
set style line 2 lc "#377eb8" # blue
# -----------------------------------------------
set xrange [0:10]
set yrange [0:1.0]
set xtics format ""
set ytics
set ylabel "y-label"
set label 1 "{/:Bold (a)}" at graph 0.05, 0.9
plot f(x,a1,b1,c1) w l ls 1 notitle, f(x,a2,b2,c2) w l ls 2 notitle
# -----------------------------------------------
unset ylabel
set ytics format ""
set y2tics format ""
set y2label "y2-label"
set label 1 "{/:Bold (b)}"
plot f(x,a1,b1,c1) w l ls 1 title "Your title 1", f(x,a2,b2,c2) w l ls 2 title "Your title 2"
# -----------------------------------------------
unset y2tics
unset y2label
set xtics 0,2,9 format "%g"
set ytics 0,0.2,0.9 format "%g"
set ylabel "y-label"
set label 1 "{/:Bold (c)}"
plot f(x,a1,b1,c1) w l ls 1 notitle, f(x,a2,b2,c2) w l ls 2 notitle
# -----------------------------------------------
unset ylabel
set xtics 0,2,10
set xlabel "common x-label" offset screen -0.20,0.0
set ytics format ""
set y2tics
set y2label "y2-label"
set label 1 "{/:Bold (d)}"
plot f(x,a1,b1,c1) w l ls 1 notitle, f(x,a2,b2,c2) w l ls 2 notitle
# -----------------------------------------------
Result

Plotting histogram+linespoints in Gnuplot

I would like to connect selected bars in a histogram with linespoints. Now
I have created the histogram using the following code in Gnuplot:
set terminal postscript eps enhanced colour font 'Times-Roman,12' size 6in,4in
set output "LS_Figure_Histogram_New_2019_III.eps"
set xtics out scale 1.5
set ytics out scale 1.5
set y2tics out scale 1.5
set ytics nomirror
set yrange [-3.50:-3.70]
set y2range [0:45]
set key off
set tics font ", 14"
set xlabel "Experiment No." font ",16"
set ylabel "Li^{+}|Li vs. Cl^{-}|Cl_{2} (V)" font ",16"
set y2label "Residual Current Density (mA/cm^{2})" font ",16"
set key autotitle columnheader
set key inside left horizontal
set style fill solid 1.00 noborder
set style histogram clustered gap 1 title textcolor lt -1
set style data histograms
plot 'LS_Histogram_Comp_2019.dat' using 2:xtic(1) ls 2 ti col axis x1y1, '' u 3:xticlabels(1) ls 4 ti col axis x1y2
The data file is as given below
# Histogram_Comparison of onset potential & Residual current density
Experimental "Li^{+}|Li (V)" "Res. Current Density (mA/cm^{2})"
1 -3.64469 31.3
2 -3.65257 11.2
3 -3.66159 32.39
4 -3.66536 13.41
5 -3.66314 16.3
6 -3.64556 10.3
7 -3.64383 10.08
8 -3.63042 9.96
9 -3.65344 9.59
10 -3.64383 8.44
11 -3.64859 11.1
12 -3.63919 27.6
13 -3.64204 9.78
14 -3.62692 30.96
15 -3.64348 18.22
16 -3.6362 32.05
17 -3.62831 20.1
18 -3.62984 42.32
19 -3.63764 24.8
I wish to connect bars corresponding to Experimental 12, 14, 16 and 18 (using col 1 and 3 data) and bars 13, 15, 17 and 19 (using col 1 and 3 data) using linespoints.
Is there a way to do it in Gnuplot?
Try this
set terminal postscript eps enhanced colour font 'Times-Roman,12' size 6in,4in
set output "LS_Figure_Histogram_New_2019_III.eps"
set xtics out scale 1.5
set ytics out scale 1.5
set y2tics out scale 1.5
set ytics nomirror
set yrange [-3.50:-3.70]
set y2range [0:45]
set key off
set tics font ", 14"
set xlabel "Experiment No." font ",16"
set ylabel "Li^{+}|Li vs. Cl^{-}|Cl_{2} (V)" font ",16"
set y2label "Residual Current Density (mA/cm^{2})" font ",16"
set key autotitle columnheader
set key inside left horizontal
set style fill solid 1.00 noborder
set style histogram clustered gap 1 title textcolor lt -1
# ----------------------------------------
set rmargin screen 0.9
set lmargin screen 0.1
set bmargin screen 0.1
set multiplot
# ----------------------------------------
set style data histograms
plot 'LS_Histogram_Comp_2019.dat' using 2:xtic(1) ls 2 ti col axis x1y1, '' u 3:xticlabels(1) ls 4 ti col axis x1y2
# ----------------------------------------
unset tics
unset xlabel
unset ylabel
unset y2label
set xrange [0:20]
set yrange [0:45]
plot 'LS_Histogram_Comp_2019.dat' \
skip 12 every 2 using 1:3 w linespoints ls 1 lw 4 not,\
'' skip 13 every 2 using 1:3 w linespoints ls 3 lw 4 not
The result

gnuplot epslatex terminal problematic dvi or ps output

I am using the epslatex terminal to generate eps figures with gnuplot 4.6.4.
However, I am having problem with this script
# reset
reset
#
sz = 1.4
rx = 10.0/7.0
#
set style line 1 lt 1 pointsize 1
# blue line
set style line 2 lt 12 pointsize 1
#
set terminal epslatex size rx*sz,2*sz color standalone
set output 'output.tex'
set multiplot layout 2,2
# Figure 1,1
set tmargin 0
set bmargin 0
set lmargin at screen 0.05
set rmargin at screen 0.475
set format x ""
set xrange [30:130]
set ylabel offset 2,0 "Y label [sec]"
unset xlabel
set grid
set yrange [0:9]
set ytics ("" 0, "1" 1, "2" 2, "3" 3, "4" 4, \
"5" 5, "6" 6, "7" 7, "8" 8, "" 9)
unset key
plot "./inp" u 1:2 t "tsL" w lp ls 1, \
"" u 1:3 t "vL" w lp ls 2
#
# Figure 1,2
set bmargin 0
set tmargin 0
set lmargin at screen 0.525
set rmargin at screen 0.95
set format x ""
set format y ""
set xrange [30:130]
set yrange [0:9]
#set mytics 2
unset ylabel
unset xlabel
set grid
plot "./inp" u 1:2 t "tsL" w lp ls 1, \
"" u 1:3 t "vL" w lp ls 2
# Figure 2,1
set tmargin 0
set bmargin 0
set lmargin at screen 0.05
set rmargin at screen 0.475
set format x "%g"
set format y "%g"
set xrange [30:130]
set ylabel offset 2,0 "Ylabel"
set xlabel offset 0,0.6 "neig"
set grid
set yrange [0:9]
set ytics ("" 0, "1" 1, "2" 2, "3" 3, "4" 4, \
"5" 5, "6" 6, "7" 7, "8" 8, "" 9)
unset key
set xtics ("40" 40, "" 60 , "80" 80,\
"" 100, "120" 120)
set mxtics 2
plot "./inp" u 1:2 t "tsL" w lp ls 1, \
"" u 1:3 t "vL" w lp ls 2
#
# Figure 2,2
set bmargin 0
set tmargin 0
set lmargin at screen 0.525
set rmargin at screen 0.95
set format y ""
set format x "%g"
set xrange [30:130]
set yrange [0:9]
#set ylabel "Ylabel"
unset ylabel
set xlabel offset 0,0.6 "neig"
set grid
set xtics ("40" 40, "" 60 , "80" 80,\
"" 100, "120" 120)
set mxtics 2
plot "./inp" u 1:2 t "tsL" w lp ls 1, \
"" u 1:3 t "vL" w lp ls 2
#
unset multiplot
#
set output
with the input file inp which includes
40 1 3
60 2 4
80 3 5
100 4 6
120 5 7
If I compile the document, everything goes fine. However, there is a line missing in dvi file and the labels seem to be at wrong location. After that, if I execute "dvips output.dvi", I get a completely wrong ps output without any labels and ytics at the wrong location. What is my mistake with this implementation?
The dvi output is usually wrong, especially the labels, because these are typeset with Postscript operations, which aren't interpreted correctly by many dvi viewers.
Concerning the labels, your left margins are too small, so that the labels are outside of the image. For you example I had to use
set lmargin at screen 0.2
set ylabel offset 0.5,0 "Y label [sec]"
for Figure 1,1 in order to have reasonable margins and see all labels (ytic labels and ylabel). The ytics are ok.
In the same manner you have to fix the other settings of lmargin and rmargin of the other subfigures, and also the bmargin of the bottom row in order to see the xlabel and the xtic labels.
And you don't need to set the ytics manually. Use
set ytics 1,1,8 # tics from 1 to 8 in steps of 1
set xtics 40 # distance of 40 between tics.
Margins and plot area
Some remarks about the margins, plot area and canvas size.
The image size (i.e. the canvas size) is given by the size terminal option (e.g. set terminal pngcairo size 800,400).
Usually, the size and position of the plotting area inside the canvas is determined automatically based on several points:
Font size
Presence and position of xlabel, ylabel etc, title, key being outside, colorbox, length of tic labels and so on.
The plotting area can be changed relative to the automatically determined one by set size and set origin (and for splot it can be scaled with set view).
The plotting area can also be set fixed by specifying explicit margins. In this case the user has to care about providing large enough margins to fit in all the elements. The margins can be specified independently with set lmargin, set rmargin, set bmargin and set tmargin. Their values can be specified in two ways:
set tmargin 1 leaves a top margin equivalent to one character height.
set tmargin at screen 0.95 leaves a top margin of 5% of the total canvas size.

shorten the distance in between plots in multiplot

I have to plot a multiplot comprising two columns and five rows. I have plotted that but I find the distance in between the plots are big and I want to reduce them. I used the last sample coding (template) as in the website ( http://www.gnuplot.info/demo_canvas/layout.html ). I tried to adjust the top and bottom margin parameters. If I use smaller values the label for x-axis disappears and the distance between plots shortened. So I have to use big values. I just wonder is there any other way to bring the plot nearer to each other? I have given the coding for plot below for your view.
I would be glad to get some insights on this issue.
Thanks in advance
#!/usr/bin/gnuplot
# SET TERMINAL
set terminal postscript color enhanced "Arial" 10 #dashed lw 1 "Helvetica" 14
set output "plot-distribution-isoMalto-thermo.ps"
# SET MACRO
set macro
labelFONT="font 'Arial,20'"
scaleFONT="font 'Arial,14'"
graph="using 1:2"
axislabelFONT="font 'Arial,18' "
#main_titleFONT="font 'times,14'"
graphLabel="at 120,9000 font 'Arial,20' "
position_orienation="at -50,18000 rotate right"
color="linecolor rgb 'black' "
layer1=" w l lt 1 lw 3 lc rgb 'black'"
layer3=" w l lt 3 lw 3 lc rgb 'red' "
layer2=" w l lt 2 lw 3 lc rgb 'green'"
layer4=" w l lt 4 lw 3 lc rgb 'blue'"
# SET MARGINS
set tmargin 0.5
set bmargin 4.0
set lmargin 15
set rmargin 3
# SET RANGE
set xrange [0:180]
set yrange [0:12000]
set xtics nomirror 0, 60, 180 #scaleFONT
set ytics 0, 3000, 12000 #scaleFONT
set format x ""
# MULTIPLOT START
set multiplot layout 5, 2 #title "Multiplot layout 5, 2"
set nokey
# PLOTTING STARTS
#plot1
#set title "Plot 1"
set xtics nomirror
set label 1 "(a)" #graphLabel
plot "angle_output-thermo-malto-L1.dat" #layer1,\
"angle_output-thermo-malto-L3.dat" #layer3
#plot2
#set title "Plot 2"
set label 1 "(b)" #graphLabel
plot "angle_output-thermo-malto-L2.dat" #layer2 ,\
"angle_output-thermo-malto-L4.dat" #layer4
#plot3
#set title "Plot 3"
set label 1 "(c)" #graphLabel
plot "angle_output-thermo-bcmChain1-L1.dat" #layer1 ,\
"angle_output-thermo-bcmChain1-L3.dat" #layer3
#plot4
#set title "Plot 4"
set label 1 "(d)" #graphLabel
plot "angle_output-thermo-bcmChain1-L2.dat" #layer2 ,\
"angle_output-thermo-bcmChain1-L4.dat" #layer4
#plot5
#set title "Plot 5"
set label 1 "(e)" #graphLabel
set label 2 "Distribution / N" #position_orienation #labelFONT
plot "angle_output-thermo-bcmChain2-L1.dat" #layer1 ,\
"angle_output-thermo-bcmChain2-L3.dat" #layer3
#plot6
#set title "Plot 6"
set nolabel
set label 1 "(f)" #graphLabel
plot "angle_output-thermo-bcmChain2-L2.dat" #layer2 ,\
"angle_output-thermo-bcmChain2-L4.dat" #layer4
#plot7
#set title "Plot 7"
set label 1 "(g)" #graphLabel
plot "angle_output-thermo-cello-L1.dat" #layer1 ,\
"angle_output-thermo-cello-L3.dat" #layer3
#plot8
#set title "Plot 8"
set label 1 "(h)" #graphLabel
plot "angle_output-thermo-cello-L2.dat" #layer2 ,\
"angle_output-thermo-cello-L4.dat" #layer4
# for plot 9 and 10
unset yrange
set yrange [0:16000]
set ytics 0, 4000, 16000
set key
#plot9
#set title "Plot 9"
set label 1 "(i)" #graphLabel
set format x
plot "angle_output-thermo-isomalto-L1.dat" #layer1 title "layer1",\
"angle_output-thermo-isomalto-L3.dat" #layer3 title "layer3"
#plot10
#set title "Plot 10"
set label 1 "(j)" #graphLabel
set label "Angle in {/Symbol q} / deg" at -90,-8500 #labelFONT
set format x
plot "angle_output-thermo-isomalto-L2.dat" #layer2 title "layer2",\
"angle_output-thermo-isomalto-L4.dat" #layer4 title "layer4"
# END MULTIPLOT
unset multiplot
#reset
#pause -1
I know this is an old question, but it might be possible to do something with set size to increase the size of each plot (optionally, a set origin for each plot might be necessary). Otherwise, your best bet is to use set lmargin,set rmargin, set bmargin and set tmargin.
You can use set ?margin at ... to set the margin relative to screen coordinates (as opposed to character coordinates in the form you have put it. This will allow you to place the plots exactly where you want to. see http://gnuplot.sourceforge.net/demo/margins.html

Resources