I am trying to plot multiple graphs using "multiplot" option from gnuplot.
The figure I plot was as below.
I have a small problem but I dont know how to solve this. The problem is regarding the scale of every individual plot. If one notice, scale for every plot a, b, c, d and e is different. For every plot I used different set xrange values. So, I understand gnuplot tried to stretched the plots to fit into the given width limit. Due to that, the scale along horizontal axis do not evenly spaced.
I want the scale to be evenly spaced for every plot especially for horizontal axis.
Below I have given the full code for your view.
How I can get this done?
Many thanks in advance.
#!/usr/bin/gnuplot
########################################################################################
mpl_top = 0.4 #inch outer top margin, title goes here
mpl_bot = 0.7 #inch outer bottom margin, x label goes here
mpl_left = 0.3 #inch outer left margin, y label goes here #vj
mpl_right = 0.8 #inch outer right margin, y2 label goes here #vj
mpl_height = 1.0 #inch height of individual plots
mpl_width = 2.2 #inch width of individual plots #vj
mpl_dx = 0.1 #inch inter-plot horizontal spacing
mpl_dy = 0.4 #inch inter-plot vertical spacing
mpl_ny = 5 #number of rows
mpl_nx = 1 #number of columns
# calculate full dimensions
xsize = mpl_left+mpl_right+(mpl_width*mpl_nx)+(mpl_nx-1)*mpl_dx
ysize = mpl_top+mpl_bot+(mpl_ny*mpl_height)+(mpl_ny-1)*mpl_dy
# placement functions
# rows are numbered from bottom to top
bot(n) = (mpl_bot+(n-1)*mpl_height+(n-1)*mpl_dy)/ysize
top(n) = 1-((mpl_top+(mpl_ny-n)*(mpl_height+mpl_dy))/ysize)
# columns are numbered from left to right
left(n) = (mpl_left+(n-1)*mpl_width+(n-1)*mpl_dx)/xsize
right(n) = 1-((mpl_right+(mpl_nx-n)*(mpl_width+mpl_dx))/xsize)
#=================================================================
#set terminal postscript eps enhanced color dl 2.0 size xsize,ysize "Helvetica" 28
##set encoding iso_8859_1
##set tics scale 1
#set output 'nxm_plot.eps'
set terminal pngcairo size 650,650 enhanced dash #font "Arial-Bold,13" #fontscale 1.20
set output "Fill-Multi-plot-LDP-lyoSystemLast50ns.png"
set encoding iso_8859_1
set offsets
set autoscale fix
set size 1,1
set nokey
# define x-axis settings for all subplots
#set xrange [-30:30]
set yrange [0:3]
set xlabel ''
#set format x ''
set xtic auto
#set xtics 5 #pi
#set mxtics 4
#### VJ DEFINITION
#set style line 4 lt 4 lw 10 # Please DISABLE pause -1
#########################################################################################
set style line 1 lt 1 lw 1.5 lc rgb "red"
set style line 2 lt 3 lw 1.5 lc rgb "red"
set style line 3 lt 5 lw 1.5 lc rgb "red"
set style line 4 lt 1 lw 1.5 lc rgb "black"
set style line 5 lt 3 lw 1.5 lc rgb "black"
set style line 6 lt 5 lw 1.5 lc rgb "black"
set style line 7 lt 1 lw 1.5 lc rgb "green"
set style line 8 lt 3 lw 1.5 lc rgb "green"
set style line 9 lt 5 lw 1.5 lc rgb "green"
set style line 10 lt 1 lw 1.5 lc rgb "blue"
set style line 11 lt 3 lw 1.5 lc rgb "blue"
set style line 12 lt 5 lw 1.5 lc rgb "blue"
set style line 13 lt 1 lw 1.5 lc rgb "magenta"
set style line 14 lt 3 lw 1.5 lc rgb "magenta"
set style line 15 lt 5 lw 1.5 lc rgb "magenta"
set style line 16 lt 1 lw 1.5 lc rgb "#6495ED"
set style line 17 lt 3 lw 1.5 lc rgb "#6495ED"
set style line 18 lt 5 lw 1.5 lc rgb "#6495ED"
###################################################################################################
set macro
#ylabelFONT="font 'arial,16'"
labelFONT="font 'Arial,16'"
scaleFONT="font 'Arial-Bold,14'"
scaleFONtt="font 'Helvetica,10'"
keyFONT="font 'Arial,12'"
#graph="using 1:2 with lines lw 1 "
###################################################################################################
# start plotting
set multiplot
#-----------------------------------------------
# subplot 1-5
# set horizontal margins for first column
set lmargin at screen left(1)
set rmargin at screen right(1)
# set horizontal margins for third row (top)
set tmargin at screen top(5)
set bmargin at screen bot(5)
set label "(a)" at -1.5,2.5 #labelFONT
set title ''
unset ylabel
set xrange [-20.0:20.0]
set format y "" #"%-2.1f"
plot "malto12per-000-050ns_only_HEAD.dat" using 1:2 title '1-050ns' w l ls 1 ,\
"malto12per-000-050ns_only_TAIL.dat" using 1:2 title '1-050ns' w l ls 2 ,\
"malto12per-000-050ns_only_WATER.dat" using 1:2 title '1-050ns' w l ls 3 ,\
"malto12per-051-100ns_only_HEAD.dat" using 1:2 title '51-100ns' w l ls 4 ,\
"malto12per-051-100ns_only_TAIL.dat" using 1:2 title '51-100ns' w l ls 5 ,\
"malto12per-051-100ns_only_WATER.dat" using 1:2 title '51-100ns' w l ls 6 ,\
"malto12per-101-150ns_only_HEAD.dat" using 1:2 title '101-150ns' w l ls 7 ,\
"malto12per-101-150ns_only_TAIL.dat" using 1:2 title '101-150ns' w l ls 8 ,\
"malto12per-101-150ns_only_WATER.dat" using 1:2 title '101-150ns' w l ls 9 ,\
"malto12per-151-200ns_only_HEAD.dat" using 1:2 title '151-200ns' w l ls 10 ,\
"malto12per-151-200ns_only_TAIL.dat" using 1:2 title '151-200ns' w l ls 11 ,\
"malto12per-151-200ns_only_WATER.dat" using 1:2 title '151-200ns' w l ls 12 ,\
"malto12per-201-250ns_only_HEAD.dat" using 1:2 title '201-250ns' w l ls 13 ,\
"malto12per-201-250ns_only_TAIL.dat" using 1:2 title '201-250ns' w l ls 14 ,\
"malto12per-201-250ns_only_WATER.dat" using 1:2 title '201-250ns' w l ls 15 ,\
"malto12per-251-300ns_only_HEAD.dat" using 1:2 title '251-300ns' w l ls 16 ,\
"malto12per-251-300ns_only_TAIL.dat" using 1:2 title '251-300ns' w l ls 17 ,\
"malto12per-251-300ns_only_WATER.dat" using 1:2 title '251-300ns' w l ls 18
;
#-----------------------------------------------
# subplot 1-4 at top most
# set horizontal margins for first column
set lmargin at screen left(1)
set rmargin at screen right(1)
# set horizontal margins for third row (top)
set tmargin at screen top(4)
set bmargin at screen bot(4)
unset label
set label "(b)" at -1.5,2.5 #labelFONT
set title ''
unset ylabel
set xtics
set xrange [-26.2:26.2]
set format y "" #"%-2.1f"
plot "malto23per-000-050ns_only_HEAD.dat" using 1:2 title '1-050ns' w l ls 1 ,\
"malto23per-000-050ns_only_TAIL.dat" using 1:2 title '1-050ns' w l ls 2 ,\
"malto23per-000-050ns_only_WATER.dat" using 1:2 title '1-050ns' w l ls 3 ,\
"malto23per-051-100ns_only_HEAD.dat" using 1:2 title '51-100ns' w l ls 4 ,\
"malto23per-051-100ns_only_TAIL.dat" using 1:2 title '51-100ns' w l ls 5 ,\
"malto23per-051-100ns_only_WATER.dat" using 1:2 title '51-100ns' w l ls 6 ,\
"malto23per-101-150ns_only_HEAD.dat" using 1:2 title '101-150ns' w l ls 7 ,\
"malto23per-101-150ns_only_TAIL.dat" using 1:2 title '101-150ns' w l ls 8 ,\
"malto23per-101-150ns_only_WATER.dat" using 1:2 title '101-150ns' w l ls 9 ,\
"malto23per-151-200ns_only_HEAD.dat" using 1:2 title '151-200ns' w l ls 10 ,\
"malto23per-151-200ns_only_TAIL.dat" using 1:2 title '151-200ns' w l ls 11 ,\
"malto23per-151-200ns_only_WATER.dat" using 1:2 title '151-200ns' w l ls 12 ,\
"malto23per-201-250ns_only_HEAD.dat" using 1:2 title '201-250ns' w l ls 13 ,\
"malto23per-201-250ns_only_TAIL.dat" using 1:2 title '201-250ns' w l ls 14 ,\
"malto23per-201-250ns_only_WATER.dat" using 1:2 title '201-250ns' w l ls 15 ,\
"malto23per-251-300ns_only_HEAD.dat" using 1:2 title '251-300ns' w l ls 16 ,\
"malto23per-251-300ns_only_TAIL.dat" using 1:2 title '251-300ns' w l ls 17 ,\
"malto23per-251-300ns_only_WATER.dat" using 1:2 title '251-300ns' w l ls 18
;
#-----------------------------------------------
# subplot 1-3
# set horizontal margins for first column
set lmargin at screen left(1)
set rmargin at screen right(1)
# set horizontal margins for second row (middle)
set tmargin at screen top(3)
set bmargin at screen bot(3)
unset label
set label "(c)" at -1.5,2.5 #labelFONT
set title ''
set ylabel "Number Density" #labelFONT
set xrange [-24.2:24.2]
set format y "" #"%-1.1f"
plot "bcm25perR-000-050ns_only_HEAD.dat" using 1:2 title '1-050ns' w l ls 1 ,\
"bcm25perR-000-050ns_only_TAIL.dat" using 1:2 title '1-050ns' w l ls 2 ,\
"bcm25perR-000-050ns_only_WATER.dat" using 1:2 title '1-050ns' w l ls 3 ,\
"bcm25perR-051-100ns_only_HEAD.dat" using 1:2 title '51-100ns' w l ls 4 ,\
"bcm25perR-051-100ns_only_TAIL.dat" using 1:2 title '51-100ns' w l ls 5 ,\
"bcm25perR-051-100ns_only_WATER.dat" using 1:2 title '51-100ns' w l ls 6 ,\
"bcm25perR-101-150ns_only_HEAD.dat" using 1:2 title '101-150ns' w l ls 7 ,\
"bcm25perR-101-150ns_only_TAIL.dat" using 1:2 title '101-150ns' w l ls 8 ,\
"bcm25perR-101-150ns_only_WATER.dat" using 1:2 title '101-150ns' w l ls 9 ,\
"bcm25perR-151-200ns_only_HEAD.dat" using 1:2 title '151-200ns' w l ls 10 ,\
"bcm25perR-151-200ns_only_TAIL.dat" using 1:2 title '151-200ns' w l ls 11 ,\
"bcm25perR-151-200ns_only_WATER.dat" using 1:2 title '151-200ns' w l ls 12 ,\
"bcm25perR-201-250ns_only_HEAD.dat" using 1:2 title '201-250ns' w l ls 13 ,\
"bcm25perR-201-250ns_only_TAIL.dat" using 1:2 title '201-250ns' w l ls 14 ,\
"bcm25perR-201-250ns_only_WATER.dat" using 1:2 title '201-250ns' w l ls 15 ,\
"bcm25perR-251-300ns_only_HEAD.dat" using 1:2 title '251-300ns' w l ls 16 ,\
"bcm25perR-251-300ns_only_TAIL.dat" using 1:2 title '251-300ns' w l ls 17 ,\
"bcm25perR-251-300ns_only_WATER.dat" using 1:2 title '251-300ns' w l ls 18
;
#-----------------------------------------------
# subplot 1-2
# set horizontal margins for first column
set lmargin at screen left(1)
set rmargin at screen right(1)
# set horizontal margins for second row (middle)
set tmargin at screen top(2)
set bmargin at screen bot(2)
unset label
set label "(d)" at -1.5,2.5 #labelFONT
set title ''
unset ylabel
set xrange [-24.8:24.8]
set format y "" #"%-1.1f"
plot "bcm25perS-000-050ns_only_HEAD.dat" using 1:2 title '1-050ns' w l ls 1 ,\
"bcm25perS-000-050ns_only_TAIL.dat" using 1:2 title '1-050ns' w l ls 2 ,\
"bcm25perS-000-050ns_only_WATER.dat" using 1:2 title '1-050ns' w l ls 3 ,\
"bcm25perS-051-100ns_only_HEAD.dat" using 1:2 title '51-100ns' w l ls 4 ,\
"bcm25perS-051-100ns_only_TAIL.dat" using 1:2 title '51-100ns' w l ls 5 ,\
"bcm25perS-051-100ns_only_WATER.dat" using 1:2 title '51-100ns' w l ls 6 ,\
"bcm25perS-101-150ns_only_HEAD.dat" using 1:2 title '101-150ns' w l ls 7 ,\
"bcm25perS-101-150ns_only_TAIL.dat" using 1:2 title '101-150ns' w l ls 8 ,\
"bcm25perS-101-150ns_only_WATER.dat" using 1:2 title '101-150ns' w l ls 9 ,\
"bcm25perS-151-200ns_only_HEAD.dat" using 1:2 title '151-200ns' w l ls 10 ,\
"bcm25perS-151-200ns_only_TAIL.dat" using 1:2 title '151-200ns' w l ls 11 ,\
"bcm25perS-151-200ns_only_WATER.dat" using 1:2 title '151-200ns' w l ls 12 ,\
"bcm25perS-201-250ns_only_HEAD.dat" using 1:2 title '201-250ns' w l ls 13 ,\
"bcm25perS-201-250ns_only_TAIL.dat" using 1:2 title '201-250ns' w l ls 14 ,\
"bcm25perS-201-250ns_only_WATER.dat" using 1:2 title '201-250ns' w l ls 15 ,\
"bcm25perS-251-300ns_only_HEAD.dat" using 1:2 title '251-300ns' w l ls 16 ,\
"bcm25perS-251-300ns_only_TAIL.dat" using 1:2 title '251-300ns' w l ls 17 ,\
"bcm25perS-251-300ns_only_WATER.dat" using 1:2 title '251-300ns' w l ls 18
;
#-----------------------------------------------
# subplot 1-1
# set horizontal margins for first column
set lmargin at screen left(1)
set rmargin at screen right(1)
# set horizontal margins for first row (bottom)
set tmargin at screen top(1)
set bmargin at screen bot(1)
unset label
set label "(e)" at -1.5,2.5 #labelFONT
set title ''
# now set a label and tic marks for the x-axis
set xlabel "Distance / ({\305})" #labelFONT
unset ylabel
set xrange [-24.1:24.1]
set format y "" # "%-1.1f"
plot "bcm25perRS-000-050ns_only_HEAD.dat" using 1:2 title '1-050ns' w l ls 1 ,\
"bcm25perRS-000-050ns_only_TAIL.dat" using 1:2 title '1-050ns' w l ls 2 ,\
"bcm25perRS-000-050ns_only_WATER.dat" using 1:2 title '1-050ns' w l ls 3 ,\
"bcm25perRS-051-100ns_only_HEAD.dat" using 1:2 title '51-100ns' w l ls 4 ,\
"bcm25perRS-051-100ns_only_TAIL.dat" using 1:2 title '51-100ns' w l ls 5 ,\
"bcm25perRS-051-100ns_only_WATER.dat" using 1:2 title '51-100ns' w l ls 6 ,\
"bcm25perRS-101-150ns_only_HEAD.dat" using 1:2 title '101-150ns' w l ls 7 ,\
"bcm25perRS-101-150ns_only_TAIL.dat" using 1:2 title '101-150ns' w l ls 8 ,\
"bcm25perRS-101-150ns_only_WATER.dat" using 1:2 title '101-150ns' w l ls 9 ,\
"bcm25perRS-151-200ns_only_HEAD.dat" using 1:2 title '151-200ns' w l ls 10 ,\
"bcm25perRS-151-200ns_only_TAIL.dat" using 1:2 title '151-200ns' w l ls 11 ,\
"bcm25perRS-151-200ns_only_WATER.dat" using 1:2 title '151-200ns' w l ls 12 ,\
"bcm25perRS-201-250ns_only_HEAD.dat" using 1:2 title '201-250ns' w l ls 13 ,\
"bcm25perRS-201-250ns_only_TAIL.dat" using 1:2 title '201-250ns' w l ls 14 ,\
"bcm25perRS-201-250ns_only_WATER.dat" using 1:2 title '201-250ns' w l ls 15 ,\
"bcm25perRS-251-300ns_only_HEAD.dat" using 1:2 title '251-300ns' w l ls 16 ,\
"bcm25perRS-251-300ns_only_TAIL.dat" using 1:2 title '251-300ns' w l ls 17 ,\
"bcm25perRS-251-300ns_only_WATER.dat" using 1:2 title '251-300ns' w l ls 18
;
#----------------------------------------------------
set size 0.3,0.5
set origin -0.56,-0.35
set bmargin at screen 0
#set key at screen 0.85,screen 0.45 Left reverse spacing 1.0 samplen 1.0 maxcols 1 maxrows 6 #keyFONT
set key at screen 1.00,screen 0.45 maxcols 3 maxrows 6 #keyFONT
#set key center left
set border 0
unset xlabel
unset ylabel
unset label
unset tics
set format x ""
set format y ""
set yrange [0:1]
plot 2 ls 1 t '1-50ns', \
2 ls 4 t '51-100ns', \
2 ls 7 t '101-150ns', \
2 ls 10 t '151-200ns', \
2 ls 13 t '201-250ns', \
2 ls 16 t '251-300ns'
;
unset multiplot
If I understood you correctly, you want the units to have the same length for all graphs. You can dynamically set the margins to obtain this effect with a do loop. Basically you'll need to define the xranges at the beginning and also the maximum range that you will find (you could do this also automatically with a bit more work). The following code should do what you want (read the comments for further info):
# This function returns the ranges for each graph,
# I have only defined 3
range(i)=(i == 1 ? "-20 20" : \
i == 2 ? "-25 25" : \
i == 3 ? "-15 15" : 1/0)
# Number of graphs and maxrange
N = 3; maxrange = 50.
set xtics 5.
set multiplot
# Loop
do for [i=1:N] {
# Set the margins
set tmargin at screen 0.98-(i-1.)/N
set bmargin at screen 0.74-(i-1.)/N
# Set range and calculate total range for graph i
set xrange [word(range(i),1) : word(range(i),2)]
totalrange = word(range(i),2) - word(range(i),1)
# Center the graphs at 0.55 and scale them depending on their range
set lmargin at screen 0.55-0.43*totalrange/maxrange
set rmargin at screen 0.55+0.43*totalrange/maxrange
# Plot
plot sin(x) not
}
Of course there is room for plenty of customization here.
You can define your functions also depending on the label i so they change through the loop:
f(x,i) = (i == 1 ? sin(x) : \
i == 2 ? cos(x) : \
i == 3 ? tan(x) : 1/0)
.
.
.
plot f(x,i)
If you have data files, you can do the same in this way:
datafiles = "data1 data2 data3"
.
.
.
plot word(datafiles,i)
Likewise with the styles and so on:
set style line 1 lw 1
set style line 2 lw 2
set style line 3 lw 3
.
.
.
plot f(x,i) ls i
Finally, if you want complete control (e.g. you are mixing functions and datafile or something else) you can define if statements within the for loop:
.
.
.
if (i == 1) {plot sin(x)}
if (i == 2) {plot cos(x)}
if (i == 3) {plot "data1"}
Related
I'm trying to use Gnuplot to create a line chart. Each line is represented by a different color. What I want is the key has the same color as the line color. This is what I have right now, current version. Is it possible to set the text 'Line 2' colored as orange, 'Line 3' colored as red, etc?
This is what I wrote in the gp file:
set xlabel'x-axis'; \
set xrange[0:25];\
set ylabel 'y-axis';\
set yrange [2:9];\
set key left top;
p 'test.dat' using 1:2 w linespoints lw 5 lc rgb '#aadc32' pt 17 title 'Line 1' ,\
'test.dat' using 1:9 w linespoints lw 5 lc 'orange' lt 1 title 'Line 2',\
'test.dat' using 1:6 w linespoints lw 5 lc 'red' lt 8 title 'Line 3',\
'test.dat' using 1:7 w linespoints lw 5 lc 'violet' pt 6 title 'Line 4',\'test.dat' using 1:8 w linespoints lw 5 lc rgb '#b5367a' pt 19 title 'Line 5',\
'test.dat' using 1:3 w linespoints lw 5 lc 'cyan' pt 9 title'Line 6',\
'test.dat' using 1:4 w linespoints lw 5 lc 'blue' lt 9 title 'Line 7',\
'test.dat' using 1:10 w linespoints lw 5 lc rgb '#1c1044' lt 5 title 'Line 8',\
Thank you so much.
Unfortunately not. The plot title does not (now, gp5.2pl0) recognise the "textcolor" specifier.
plot x lw 3 lc rgb "blue" title "x" tc rgb "blue" # doesn't work
You can only print an empty (" ") plot title, and overprint it with a coloured label
set label 1 at 8,1 "bluetitle" tc rgb "blue"
That requires some fiddling with the placement of the label, of course.
You might put up a feature request on https://sourceforge.net/p/gnuplot/feature-requests/
I am trying to plot five graphs (a,b,c,d,e) in a column order as shown below.
The x-scale for each plot is different and they are not in a vertical line but graphs (c), (d) and (e) have almost similar x range values, that is 24.8.
When I plot these graphs in column order, I find graph labeled (a) and (b) are stretch and compressed respectively.
However, graphs labeled (c), (d) and (e) are having a same scale length.
I have drawn a red line vertically to show how the x-scale of each graph is aligned. (Please see the attached figure)
The gnuplot script that I used is given below.
#!/usr/bin/env gnuplot
#########################################################################################
#OUTPUT
#PNG
set terminal pngcairo size 600,550 enhanced dash #font "Arial-Bold,13" #fontscale 1.20
set output "zMulti-plot-LDP-lyoSystems.png"
#########################################################################################
set style line 1 lt 1 lw 1.5 lc rgb "red"
set style line 2 lt 3 lw 1.5 lc rgb "red"
set style line 3 lt 5 lw 1.5 lc rgb "red"
set style line 4 lt 1 lw 1.5 lc rgb "black"
set style line 5 lt 3 lw 1.5 lc rgb "black"
set style line 6 lt 5 lw 1.5 lc rgb "black"
set style line 7 lt 1 lw 1.5 lc rgb "green"
set style line 8 lt 3 lw 1.5 lc rgb "green"
set style line 9 lt 5 lw 1.5 lc rgb "green"
set style line 10 lt 1 lw 1.5 lc rgb "blue"
set style line 11 lt 3 lw 1.5 lc rgb "blue"
set style line 12 lt 5 lw 1.5 lc rgb "blue"
set style line 13 lt 1 lw 1.5 lc rgb "magenta"
set style line 14 lt 3 lw 1.5 lc rgb "magenta"
set style line 15 lt 5 lw 1.5 lc rgb "magenta"
set style line 16 lt 1 lw 1.5 lc rgb "#6495ED"
set style line 17 lt 3 lw 1.5 lc rgb "#6495ED"
set style line 18 lt 5 lw 1.5 lc rgb "#6495ED"
#########################################################################################
set macro
#ylabelFONT="font 'arial,16'"
labelFONT="font 'Arial,18'"
scaleFONT="font 'Arial-Bold,14'"
keyFONT="font 'Arial,10'"
#graph="using 1:2 with lines lw 1 "
#########################################################################################
xsize = 0.80
ysize = 0.22
xorigin = 0.002
yorigin = 0.02
#####################################################################
set xrange [-24.8:24.8]
set yrange [0:2.5]
set xtic auto #scaleFONT # set xtics automatically
#set ytic 0,0.2,0.4 #scaleFONT # set ytics automatically
set ytic " " #0,0.2,0.4 #scaleFONT # set ytics automatically
unset key
set size 1.0,1.0
set multiplot
# plot A
set ylabel ""
set label "(e)" at 0,0.60 #scaleFONT
set origin xorigin,yorigin
set size xsize,(ysize+0.015)
plot "bcm25perRS-000-050ns_only_HEAD.dat" using 1:2 title '1-050ns' w l ls 1 ,\
"bcm25perRS-000-050ns_only_TAIL.dat" using 1:2 title '1-050ns' w l ls 2 ,\
"bcm25perRS-000-050ns_only_WATER.dat" using 1:2 title '1-050ns' w l ls 3 ,\
"bcm25perRS-051-100ns_only_HEAD.dat" using 1:2 title '51-100ns' w l ls 4 ,\
"bcm25perRS-051-100ns_only_TAIL.dat" using 1:2 title '51-100ns' w l ls 5 ,\
"bcm25perRS-051-100ns_only_WATER.dat" using 1:2 title '51-100ns' w l ls 6 ,\
"bcm25perRS-101-150ns_only_HEAD.dat" using 1:2 title '101-150ns' w l ls 7 ,\
"bcm25perRS-101-150ns_only_TAIL.dat" using 1:2 title '101-150ns' w l ls 8 ,\
"bcm25perRS-101-150ns_only_WATER.dat" using 1:2 title '101-150ns' w l ls 9 ,\
"bcm25perRS-151-200ns_only_HEAD.dat" using 1:2 title '151-200ns' w l ls 10 ,\
"bcm25perRS-151-200ns_only_TAIL.dat" using 1:2 title '151-200ns' w l ls 11 ,\
"bcm25perRS-151-200ns_only_WATER.dat" using 1:2 title '151-200ns' w l ls 12 ,\
"bcm25perRS-201-250ns_only_HEAD.dat" using 1:2 title '201-250ns' w l ls 13 ,\
"bcm25perRS-201-250ns_only_TAIL.dat" using 1:2 title '201-250ns' w l ls 14 ,\
"bcm25perRS-201-250ns_only_WATER.dat" using 1:2 title '201-250ns' w l ls 15 ,\
"bcm25perRS-251-300ns_only_HEAD.dat" using 1:2 title '251-300ns' w l ls 16 ,\
"bcm25perRS-251-300ns_only_TAIL.dat" using 1:2 title '251-300ns' w l ls 17 ,\
"bcm25perRS-251-300ns_only_WATER.dat" using 1:2 title '251-300ns' w l ls 18
# plot B
set xrange [-24.8:24.8]
set ylabel ""
unset label
set label "(d)" at 0,0.60 #scaleFONT
#set format x ""
set origin xorigin,(yorigin+0.19)
set size xsize,ysize+0.02
plot "bcm25perS-000-050ns_only_HEAD.dat" using 1:2 title '1-050ns' w l ls 1 ,\
"bcm25perS-000-050ns_only_TAIL.dat" using 1:2 title '1-050ns' w l ls 2 ,\
"bcm25perS-000-050ns_only_WATER.dat" using 1:2 title '1-050ns' w l ls 3 ,\
"bcm25perS-051-100ns_only_HEAD.dat" using 1:2 title '51-100ns' w l ls 4 ,\
"bcm25perS-051-100ns_only_TAIL.dat" using 1:2 title '51-100ns' w l ls 5 ,\
"bcm25perS-051-100ns_only_WATER.dat" using 1:2 title '51-100ns' w l ls 6 ,\
"bcm25perS-101-150ns_only_HEAD.dat" using 1:2 title '101-150ns' w l ls 7 ,\
"bcm25perS-101-150ns_only_TAIL.dat" using 1:2 title '101-150ns' w l ls 8 ,\
"bcm25perS-101-150ns_only_WATER.dat" using 1:2 title '101-150ns' w l ls 9 ,\
"bcm25perS-151-200ns_only_HEAD.dat" using 1:2 title '151-200ns' w l ls 10 ,\
"bcm25perS-151-200ns_only_TAIL.dat" using 1:2 title '151-200ns' w l ls 11 ,\
"bcm25perS-151-200ns_only_WATER.dat" using 1:2 title '151-200ns' w l ls 12 ,\
"bcm25perS-201-250ns_only_HEAD.dat" using 1:2 title '201-250ns' w l ls 13 ,\
"bcm25perS-201-250ns_only_TAIL.dat" using 1:2 title '201-250ns' w l ls 14 ,\
"bcm25perS-201-250ns_only_WATER.dat" using 1:2 title '201-250ns' w l ls 15 ,\
"bcm25perS-251-300ns_only_HEAD.dat" using 1:2 title '251-300ns' w l ls 16 ,\
"bcm25perS-251-300ns_only_TAIL.dat" using 1:2 title '251-300ns' w l ls 17 ,\
"bcm25perS-251-300ns_only_WATER.dat" using 1:2 title '251-300ns' w l ls 18
# plot C
set xrange [-24.4:24.4]
set ylabel ""
unset label
set label "(c)" at 0,0.60 #scaleFONT
set origin xorigin,(yorigin+0.385)
set size xsize,ysize+0.02
plot "bcm25perR-000-050ns_only_HEAD.dat" using 1:2 title '1-050ns' w l ls 1 ,\
"bcm25perR-000-050ns_only_TAIL.dat" using 1:2 title '1-050ns' w l ls 2 ,\
"bcm25perR-000-050ns_only_WATER.dat" using 1:2 title '1-050ns' w l ls 3 ,\
"bcm25perR-051-100ns_only_HEAD.dat" using 1:2 title '51-100ns' w l ls 4 ,\
"bcm25perR-051-100ns_only_TAIL.dat" using 1:2 title '51-100ns' w l ls 5 ,\
"bcm25perR-051-100ns_only_WATER.dat" using 1:2 title '51-100ns' w l ls 6 ,\
"bcm25perR-101-150ns_only_HEAD.dat" using 1:2 title '101-150ns' w l ls 7 ,\
"bcm25perR-101-150ns_only_TAIL.dat" using 1:2 title '101-150ns' w l ls 8 ,\
"bcm25perR-101-150ns_only_WATER.dat" using 1:2 title '101-150ns' w l ls 9 ,\
"bcm25perR-151-200ns_only_HEAD.dat" using 1:2 title '151-200ns' w l ls 10 ,\
"bcm25perR-151-200ns_only_TAIL.dat" using 1:2 title '151-200ns' w l ls 11 ,\
"bcm25perR-151-200ns_only_WATER.dat" using 1:2 title '151-200ns' w l ls 12 ,\
"bcm25perR-201-250ns_only_HEAD.dat" using 1:2 title '201-250ns' w l ls 13 ,\
"bcm25perR-201-250ns_only_TAIL.dat" using 1:2 title '201-250ns' w l ls 14 ,\
"bcm25perR-201-250ns_only_WATER.dat" using 1:2 title '201-250ns' w l ls 15 ,\
"bcm25perR-251-300ns_only_HEAD.dat" using 1:2 title '251-300ns' w l ls 16 ,\
"bcm25perR-251-300ns_only_TAIL.dat" using 1:2 title '251-300ns' w l ls 17 ,\
"bcm25perR-251-300ns_only_WATER.dat" using 1:2 title '251-300ns' w l ls 18
# plot D
set xrange [-26.2:26.2]
set xtics auto
set ylabel ""
unset label
set label "(b)" at 0,0.60 #scaleFONT
set origin xorigin,(yorigin+0.58)
set size xsize,ysize+0.02
plot "malto23per-000-050ns_only_HEAD.dat" using 1:2 title '1-050ns' w l ls 1 ,\
"malto23per-000-050ns_only_TAIL.dat" using 1:2 title '1-050ns' w l ls 2 ,\
"malto23per-000-050ns_only_WATER.dat" using 1:2 title '1-050ns' w l ls 3 ,\
"malto23per-051-100ns_only_HEAD.dat" using 1:2 title '51-100ns' w l ls 4 ,\
"malto23per-051-100ns_only_TAIL.dat" using 1:2 title '51-100ns' w l ls 5 ,\
"malto23per-051-100ns_only_WATER.dat" using 1:2 title '51-100ns' w l ls 6 ,\
"malto23per-101-150ns_only_HEAD.dat" using 1:2 title '101-150ns' w l ls 7 ,\
"malto23per-101-150ns_only_TAIL.dat" using 1:2 title '101-150ns' w l ls 8 ,\
"malto23per-101-150ns_only_WATER.dat" using 1:2 title '101-150ns' w l ls 9 ,\
"malto23per-151-200ns_only_HEAD.dat" using 1:2 title '151-200ns' w l ls 10 ,\
"malto23per-151-200ns_only_TAIL.dat" using 1:2 title '151-200ns' w l ls 11 ,\
"malto23per-151-200ns_only_WATER.dat" using 1:2 title '151-200ns' w l ls 12 ,\
"malto23per-201-250ns_only_HEAD.dat" using 1:2 title '201-250ns' w l ls 13 ,\
"malto23per-201-250ns_only_TAIL.dat" using 1:2 title '201-250ns' w l ls 14 ,\
"malto23per-201-250ns_only_WATER.dat" using 1:2 title '201-250ns' w l ls 15 ,\
"malto23per-251-300ns_only_HEAD.dat" using 1:2 title '251-300ns' w l ls 16 ,\
"malto23per-251-300ns_only_TAIL.dat" using 1:2 title '251-300ns' w l ls 17 ,\
"malto23per-251-300ns_only_WATER.dat" using 1:2 title '251-300ns' w l ls 18
# plot E
set xrange [-20.0:20.0]
set xtics auto
set ylabel ""
unset label
set label "(a)" at 0,0.60 #scaleFONT
set origin xorigin,(yorigin+0.77)
set size xsize,ysize+0.02
plot "malto12per-000-050ns_only_HEAD.dat" using 1:2 title '1-050ns' w l ls 1 ,\
"malto12per-000-050ns_only_TAIL.dat" using 1:2 title '1-050ns' w l ls 2 ,\
"malto12per-000-050ns_only_WATER.dat" using 1:2 title '1-050ns' w l ls 3 ,\
"malto12per-051-100ns_only_HEAD.dat" using 1:2 title '51-100ns' w l ls 4 ,\
"malto12per-051-100ns_only_TAIL.dat" using 1:2 title '51-100ns' w l ls 5 ,\
"malto12per-051-100ns_only_WATER.dat" using 1:2 title '51-100ns' w l ls 6 ,\
"malto12per-101-150ns_only_HEAD.dat" using 1:2 title '101-150ns' w l ls 7 ,\
"malto12per-101-150ns_only_TAIL.dat" using 1:2 title '101-150ns' w l ls 8 ,\
"malto12per-101-150ns_only_WATER.dat" using 1:2 title '101-150ns' w l ls 9 ,\
"malto12per-151-200ns_only_HEAD.dat" using 1:2 title '151-200ns' w l ls 10 ,\
"malto12per-151-200ns_only_TAIL.dat" using 1:2 title '151-200ns' w l ls 11 ,\
"malto12per-151-200ns_only_WATER.dat" using 1:2 title '151-200ns' w l ls 12 ,\
"malto12per-201-250ns_only_HEAD.dat" using 1:2 title '201-250ns' w l ls 13 ,\
"malto12per-201-250ns_only_TAIL.dat" using 1:2 title '201-250ns' w l ls 14 ,\
"malto12per-201-250ns_only_WATER.dat" using 1:2 title '201-250ns' w l ls 15 ,\
"malto12per-251-300ns_only_HEAD.dat" using 1:2 title '251-300ns' w l ls 16 ,\
"malto12per-251-300ns_only_TAIL.dat" using 1:2 title '251-300ns' w l ls 17 ,\
"malto12per-251-300ns_only_WATER.dat" using 1:2 title '251-300ns' w l ls 18
# plot F
set size 0.3,0.5
set origin 0.76,0.55
set bmargin at screen 0
set key center center
set border 0
unset xlabel
unset ylabel
unset label
unset tics
set format x ""
set format y ""
set yrange [0:1]
plot 2 ls 1 t '1-50ns', \
2 ls 4 t '51-100ns', \
2 ls 7 t '101-150ns', \
2 ls 10 t '151-200ns', \
2 ls 13 t '201-250ns', \
2 ls 16 t '251-300ns'
unset multiplot
Can someone have a look into this issue and help me to get a multiplot as I shown but let the scale of each plot is align in vertical order?
It is OK if the graph size is small or big.
But I want the scale to be in line vertically.
Appreciate all your help.
Thank you.
If I edit the set xrange [-26.2:26.2] to be same for all, than I get something below.. which I dont want. I only want as how I shown in the first picture.
Basically you must adjust x-values of the plot size and origin such, that the widest plots keep their current size, and all others are shifted and squeezed according to their smaller ranges.
Since I don't have any data files and cannot test the whole script anyway, here is a sketch of what you need to do:
xsize(width) = 0.80 * width / width_max
ysize = 0.22
width_max = (2 * 26.2)
left_min = -26.2
xorigin(left) = 0.002 + (left - left_min) * xsize / width_max
yorigin = 0.02
set multiplot
# plot A
set xrange [-24.8:24.8]
set origin xorigin(-24.8),yorigin
set size xsize(2*24.8),(ysize+0.015)
plot ...
# plot B
set xrange [-24.8:24.8]
set origin xorigin(-24.8),(yorigin+0.19)
set size xsize(2*24.8),ysize+0.02
plot ...
# plot C
set xrange [-24.4:24.4]
set origin xorigin(-24.4),(yorigin+0.385)
set size xsize(2*24.4),ysize+0.02
plot ...
# plot D
set xrange [-26.2:26.2]
set origin xorigin(-26.2),(yorigin+0.58)
set size xsize(2*26.2),ysize+0.02
plot ...
# plot E
set xrange [-20.0:20.0]
set origin xorigin(-20),(yorigin+0.77)
set size xsize(2*20),ysize+0.02
plot ...
I would like to plot a legend/key, which shows the different symbols on the line. Currently my plots look like this:
Unfortunately the symbols (triangle, rectangle and circle) are not shown in the key/legend. How is it possible to add them?
I use the following gnuplot script:
set title tit font "palatino,20"
set xlabel xlbl font "palatino,20"
set ylabel ylbl font "palatino,20"
#set logscale x
set output graphfilename.".pdf"
set terminal pdf
set border linewidth 2
set style line 1 lc rgb '#0060ad' lt 1 lw 2 pt 5 # --- blue
set style line 2 lc rgb '#00ad60' lt 1 lw 2 pt 7 # red .
set style line 3 lc rgb '#ad0000' lt 1 lw 2 pt 9 # green .
set tics scale 0.8
set key below
plot file1 using ($1/1000):($2/1000000):($3/1000000):($4/1000000) notitle w yerrorbars ls 1, \
'' using ($1/1000):($2/1000000) title "Hlog" w lines ls 1,\
file2 using ($1/1000):($2/1000000):($3/1000000):($4/1000000) notitle w yerrorbars ls 2, \
'' using ($1/1000):($2/1000000) title "Iris" w lines ls 2,\
file3 using ($1/1000):($2/1000000):($3/1000000):($4/1000000) notitle w yerrorbars ls 3, \
'' using ($1/1000):($2/1000000) title "Java" w lines ls 3
Generally, you can get both lines and points, if you plot with the linespoints plotting style:
sc(x) = x*1e-6
plot file1 using ($1/1000):(sc($2)):(sc($3)):(sc($4)) notitle w yerrorbars ls 1 ps 0.5, \
'' using ($1/1000):(sc($2)) title "Hlog" w linespoints ls 1
That draws the points twice, which shouldn't be a problem unless you use transparency. I also shrinked the points which are drawn together with the errorbars to 50%, so you don't get problems with antialiasing.
As another option you could add the title only the the errorbars, in which case the legend would look like |---x---| (i.e. contain also the errorbars):
sc(x) = x*1e-6
plot file1 using ($1/1000):(sc($2)):(sc($3)):(sc($4)) title "Hlog" w yerrorbars ls 1, \
'' using ($1/1000):(sc($2)) notitle w lines ls 1
I am plotting multiplot with 11 graphs. I given the code used below:
#!/usr/bin/gnuplot
########################################################################################
#OUTPUT
set size 1.0, 1.0
#POSTCRIPT
set term postscript landscape enhanced color
set output "radial_distribution_function.ps" #
#set terminal postscript portrait enhanced color dashed "Helvetica" 8
#set output "time-density-profile-maltose.ps"
#PNG
#set terminal pngcairo size 650,450 enhanced dash
#set output "multi-plot_gauche_bcMalto-chain2-thermo.png"
# WXT
#set terminal wxt size 900,450 enhanced font 'Arial,10' dashed persist
#set style line 4 lt 4 lw 10 # Please DISABLE pause -1
#########################################################################
set style line 1 lt 1 lc rgb "#FFB6C1" lw 2.0
set style line 2 lt 1 lc rgb "black" lw 2.0
set style line 3 lt 1 lc rgb "green" lw 2.0
set style line 4 lt 1 lc rgb "blue" lw 2.0
set style line 5 lt 1 lc rgb "#8B008B" lw 2.0
set style line 6 lt 1 lc rgb "yellow" lw 2.0
#########################################################################
### START MARCRO
set macro
#ylabelFONT="font 'Arial,16'"
labelFONT="font 'Arial,12'"
scaleFONT="font 'Arial,12'"
keyFONT="font 'Arial,14'"
#graph="using 1:2 with lines lw 1 "
scaleFONT2="font 'Arial,11'"
### END MACRO
set key font ",8"
set key spacing 0.7
unset key
set autoscale # scale axes automatically
set xtic auto #scaleFONT # set xtics automatically
set ytic auto #scaleFONT # set ytics automatically
set xlabel "Distance (Angstrom)" #labelFONT
set ylabel "g(r)" #labelFONT
set xrange [0:10]
set yrange [0:5]
#set title "Density profile for isomaltose"
set multiplot layout 4,3 title ""
# PLOT_1
set label "(a) O11" at 1.5, 4 #labelFONT
plot "maltoLyo12per-ddm_O11-wat_O.dat" using 1:2 w l ls 1 title "{/Symbol b}Mal-C_{12}12%H_{2}O",\
"maltoLyo23per-ddm_O11-wat_O.dat" using 1:2 w l ls 2 title "{/Symbol b}Mal-C_{12}23%H_{2}O",\
"bcmLyo25perR-BMR_O11-wat_O.dat" using 1:2 w l ls 3 title "{/Symbol b}Mal-C_{12}C_{8}(R)25%H_{2}O",\
"bcmLyo25perS-BCS_O11-wat_O.dat" using 1:2 w l ls 4 title "{/Symbol b}Mal-C_{12}C_{8}(S)25%H_{2}O",\
"bchainRS25per-BMR_O11-wat_O.dat" using 1:2 w l ls 5 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(R)25%H_{2}O",\
"bchainRS25per-BMS_O11-wat_O.dat" using 1:2 w l ls 6 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(S)25%H_{2}O"
# PLOT_2
unset label
set label "(b) O12" at 1.5, 4 #labelFONT
plot "maltoLyo12per-ddm_O12-wat_O.dat" using 1:2 w l ls 1 title "{/Symbol b}Mal-C_{12}12%H_{2}O",\
"maltoLyo23per-ddm_O12-wat_O.dat" using 1:2 w l ls 2 title "{/Symbol b}Mal-C_{12}23%H_{2}O",\
"bcmLyo25perR-BMR_O12-wat_O.dat" using 1:2 w l ls 3 title "{/Symbol b}Mal-C_{12}C_{8}(R)25%H_{2}O",\
"bcmLyo25perS-BCS_O12-wat_O.dat" using 1:2 w l ls 4 title "{/Symbol b}Mal-C_{12}C_{8}(S)25%H_{2}O",\
"bchainRS25per-BMR_O12-wat_O.dat" using 1:2 w l ls 5 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(R)25%H_{2}O",\
"bchainRS25per-BMS_O12-wat_O.dat" using 1:2 w l ls 6 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(S)25%H_{2}O"
# PLOT_3
unset label
set label "(c) O13" at 1.5, 4 #labelFONT
plot "maltoLyo12per-ddm_O13-wat_O.dat" using 1:2 w l ls 1 title "{/Symbol b}Mal-C_{12}12%H_{2}O",\
"maltoLyo23per-ddm_O13-wat_O.dat" using 1:2 w l ls 2 title "{/Symbol b}Mal-C_{12}23%H_{2}O",\
"bcmLyo25perR-BMR_O13-wat_O.dat" using 1:2 w l ls 3 title "{/Symbol b}Mal-C_{12}C_{8}(R)25%H_{2}O",\
"bcmLyo25perS-BCS_O13-wat_O.dat" using 1:2 w l ls 4 title "{/Symbol b}Mal-C_{12}C_{8}(S)25%H_{2}O",\
"bchainRS25per-BMR_O13-wat_O.dat" using 1:2 w l ls 5 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(R)25%H_{2}O",\
"bchainRS25per-BMS_O13-wat_O.dat" using 1:2 w l ls 6 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(S)25%H_{2}O"
# PLOT_4
unset label
set label "(d) O14" at 1.5, 4 #labelFONT
plot "maltoLyo12per-ddm_O14-wat_O.dat" using 1:2 w l ls 1 title "{/Symbol b}Mal-C_{12}12%H_{2}O",\
"maltoLyo23per-ddm_O14-wat_O.dat" using 1:2 w l ls 2 title "{/Symbol b}Mal-C_{12}23%H_{2}O",\
"bcmLyo25perR-BMR_O14-wat_O.dat" using 1:2 w l ls 3 title "{/Symbol b}Mal-C_{12}C_{8}(R)25%H_{2}O",\
"bcmLyo25perS-BCS_O14-wat_O.dat" using 1:2 w l ls 4 title "{/Symbol b}Mal-C_{12}C_{8}(S)25%H_{2}O",\
"bchainRS25per-BMR_O14-wat_O.dat" using 1:2 w l ls 5 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(R)25%H_{2}O",\
"bchainRS25per-BMS_O14-wat_O.dat" using 1:2 w l ls 6 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(S)25%H_{2}O"
# PLOT_5
unset label
set label "(e) O15" at 1.5, 4 #labelFONT
plot "maltoLyo12per-ddm_O15-wat_O.dat" using 1:2 w l ls 1 title "{/Symbol b}Mal-C_{12}12%H_{2}O",\
"maltoLyo23per-ddm_O15-wat_O.dat" using 1:2 w l ls 2 title "{/Symbol b}Mal-C_{12}23%H_{2}O",\
"bcmLyo25perR-BMR_O15-wat_O.dat" using 1:2 w l ls 3 title "{/Symbol b}Mal-C_{12}C_{8}(R)25%H_{2}O",\
"bcmLyo25perS-BCS_O15-wat_O.dat" using 1:2 w l ls 4 title "{/Symbol b}Mal-C_{12}C_{8}(S)25%H_{2}O",\
"bchainRS25per-BMR_O15-wat_O.dat" using 1:2 w l ls 5 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(R)25%H_{2}O",\
"bchainRS25per-BMS_O15-wat_O.dat" using 1:2 w l ls 6 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(S)25%H_{2}O"
# PLOT_6
unset label
set label "(f) O16" at 1.5, 4 #labelFONT
plot "maltoLyo12per-ddm_O16-wat_O.dat" using 1:2 w l ls 1 title "{/Symbol b}Mal-C_{12}12%H_{2}O",\
"maltoLyo23per-ddm_O16-wat_O.dat" using 1:2 w l ls 2 title "{/Symbol b}Mal-C_{12}23%H_{2}O",\
"bcmLyo25perR-BMR_O16-wat_O.dat" using 1:2 w l ls 3 title "{/Symbol b}Mal-C_{12}C_{8}(R)25%H_{2}O",\
"bcmLyo25perS-BCS_O16-wat_O.dat" using 1:2 w l ls 4 title "{/Symbol b}Mal-C_{12}C_{8}(S)25%H_{2}O",\
"bchainRS25per-BMR_O16-wat_O.dat" using 1:2 w l ls 5 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(R)25%H_{2}O",\
"bchainRS25per-BMS_O16-wat_O.dat" using 1:2 w l ls 6 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(S)25%H_{2}O"
# PLOT_7
unset label
set label "(g) O22" at 1.5, 4 #labelFONT
plot "maltoLyo12per-ddm_O22-wat_O.dat" using 1:2 w l ls 1 title "{/Symbol b}Mal-C_{12}12%H_{2}O",\
"maltoLyo23per-ddm_O22-wat_O.dat" using 1:2 w l ls 2 title "{/Symbol b}Mal-C_{12}23%H_{2}O",\
"bcmLyo25perR-BMR_O22-wat_O.dat" using 1:2 w l ls 3 title "{/Symbol b}Mal-C_{12}C_{8}(R)25%H_{2}O",\
"bcmLyo25perS-BCS_O22-wat_O.dat" using 1:2 w l ls 4 title "{/Symbol b}Mal-C_{12}C_{8}(S)25%H_{2}O",\
"bchainRS25per-BMR_O22-wat_O.dat" using 1:2 w l ls 5 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(R)25%H_{2}O",\
"bchainRS25per-BMS_O22-wat_O.dat" using 1:2 w l ls 6 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(S)25%H_{2}O"
# PLOT_8
unset label
set label "(h) O23" at 1.5, 4 #labelFONT
plot "maltoLyo12per-ddm_O23-wat_O.dat" using 1:2 w l ls 1 title "{/Symbol b}Mal-C_{12}12%H_{2}O",\
"maltoLyo23per-ddm_O23-wat_O.dat" using 1:2 w l ls 2 title "{/Symbol b}Mal-C_{12}23%H_{2}O",\
"bcmLyo25perR-BMR_O23-wat_O.dat" using 1:2 w l ls 3 title "{/Symbol b}Mal-C_{12}C_{8}(R)25%H_{2}O",\
"bcmLyo25perS-BCS_O23-wat_O.dat" using 1:2 w l ls 4 title "{/Symbol b}Mal-C_{12}C_{8}(S)25%H_{2}O",\
"bchainRS25per-BMR_O23-wat_O.dat" using 1:2 w l ls 5 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(R)25%H_{2}O",\
"bchainRS25per-BMS_O23-wat_O.dat" using 1:2 w l ls 6 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(S)25%H_{2}O"
# PLOT_9
unset label
set label "(i) O24" at 1.5, 4 #labelFONT
plot "maltoLyo12per-ddm_O24-wat_O.dat" using 1:2 w l ls 1 title "{/Symbol b}Mal-C_{12}12%H_{2}O",\
"maltoLyo23per-ddm_O24-wat_O.dat" using 1:2 w l ls 2 title "{/Symbol b}Mal-C_{12}23%H_{2}O",\
"bcmLyo25perR-BMR_O24-wat_O.dat" using 1:2 w l ls 3 title "{/Symbol b}Mal-C_{12}C_{8}(R)25%H_{2}O",\
"bcmLyo25perS-BCS_O24-wat_O.dat" using 1:2 w l ls 4 title "{/Symbol b}Mal-C_{12}C_{8}(S)25%H_{2}O",\
"bchainRS25per-BMR_O24-wat_O.dat" using 1:2 w l ls 5 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(R)25%H_{2}O",\
"bchainRS25per-BMS_O24-wat_O.dat" using 1:2 w l ls 6 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(S)25%H_{2}O"
# PLOT_10
unset label
set label "(j) O25" at 1.5, 4 #labelFONT
plot "maltoLyo12per-ddm_O25-wat_O.dat" using 1:2 w l ls 1 title "{/Symbol b}Mal-C_{12}12%H_{2}O",\
"maltoLyo23per-ddm_O25-wat_O.dat" using 1:2 w l ls 2 title "{/Symbol b}Mal-C_{12}23%H_{2}O",\
"bcmLyo25perR-BMR_O25-wat_O.dat" using 1:2 w l ls 3 title "{/Symbol b}Mal-C_{12}C_{8}(R)25%H_{2}O",\
"bcmLyo25perS-BCS_O25-wat_O.dat" using 1:2 w l ls 4 title "{/Symbol b}Mal-C_{12}C_{8}(S)25%H_{2}O",\
"bchainRS25per-BMR_O25-wat_O.dat" using 1:2 w l ls 5 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(R)25%H_{2}O",\
"bchainRS25per-BMS_O25-wat_O.dat" using 1:2 w l ls 6 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(S)25%H_{2}O"
# PLOT_11
unset label
set label "(k) O26" at 1.5, 4 #labelFONT
unset key
plot "maltoLyo12per-ddm_O26-wat_O.dat" using 1:2 w l ls 1 title "{/Symbol b}Mal-C_{12}12%H_{2}O",\
"maltoLyo23per-ddm_O26-wat_O.dat" using 1:2 w l ls 2 title "{/Symbol b}Mal-C_{12}23%H_{2}O",\
"bcmLyo25perR-BMR_O26-wat_O.dat" using 1:2 w l ls 3 title "{/Symbol b}Mal-C_{12}C_{8}(R)25%H_{2}O",\
"bcmLyo25perS-BCS_O26-wat_O.dat" using 1:2 w l ls 4 title "{/Symbol b}Mal-C_{12}C_{8}(S)25%H_{2}O",\
"bchainRS25per-BMR_O26-wat_O.dat" using 1:2 w l ls 5 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(R)25%H_{2}O",\
"bchainRS25per-BMS_O26-wat_O.dat" using 1:2 w l ls 6 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(S)25%H_{2}O"
unset multiplot
The graph that I get is show here
What I notice from the graph is there is lot of empty space between the graphs. For example between graph (a) and (b) and also between graph (a) and (d). I want to reduce the space between them and make the graph little bigger.
What I should do to reduce the space and optimize the graph size.
Thanks in advance.
Ok, lets start :)
First, your script and your naming of the data files is perfect for iterations. So, you can define a list of file name templates with a placeholder %s, which is later substituted by the actual parameter.
So you first have an iteration over the different O11, O12 etc. values and for each of those a new plot is generated. Then you have a plot for iteration over the file names which are all placed in a single plot.
Using set linetype to define the colors allows you to make use of the automatic line type increment.
Now to your actual question:
I think the best options are to correct the offset of the labels a bit, e.g. with
set ylabel "g(r)" offset 1,0 #labelFONT
which shifts the ylabel by one character unit to the right with respect to the automatically selected position. That should give you a little bigger graph.
If that isn't enough you must start to manually set the margins. I would start by changing only the top and right margins. With e.g.
set tmargin 0
set rmargin 0
the top and right margins will be placed at the boundaries of the respective panels. With e.g. set rmargin 0.5 the right margin is set to a half character width. You must play around with these values.
Here is a shortened script. Note, that I couldn't test it, because I don't have the data files. I hope I didn't make any errors :)
#!/usr/bin/gnuplot
set term postscript landscape enhanced color
set output "radial_distribution_function.ps" #
#########################################################################
set linetype 1 lt 1 lc rgb "#FFB6C1" lw 2.0
set linetype 2 lt 1 lc rgb "black" lw 2.0
set linetype 3 lt 1 lc rgb "green" lw 2.0
set linetype 4 lt 1 lc rgb "blue" lw 2.0
set linetype 5 lt 1 lc rgb "#8B008B" lw 2.0
set linetype 6 lt 1 lc rgb "yellow" lw 2.0
#########################################################################
set macro
labelFONT="font 'Arial,12'"
scaleFONT="font 'Arial,12'"
keyFONT="font 'Arial,14'"
scaleFONT2="font 'Arial,11'"
unset key
set autoscale # scale axes automatically
set xtic auto #scaleFONT # set xtics automatically
set ytic auto #scaleFONT # set ytics automatically
set xlabel "Distance (Angstrom)" #labelFONT
set ylabel "g(r)" offset 1,0 #labelFONT
set xrange [0:10]
set yrange [0:5]
file_tmpls = "maltoLyo12per-ddm_%s-wat_O.dat ".\
"maltoLyo23per-ddm_%s-wat_O.dat ".\
"bcmLyo25perR-BMR_%s-wat_O.dat ".\
"bcmLyo25perS-BCS_%s-wat_O.dat ".\
"bchainRS25per-BMR_%s-wat_O.dat ".\
"bchainRS25per-BMS_%s-wat_O.dat "
par = "O11 O12 O13 O14 O15 O16 O22 O23 O24 O25 O26"
labels = "a b c d e f g h i j k"
label_tmpl = "(%s) %s"
# You must optimize the values, which are given in units of character widths (or heights)
set tmargin 0.5
set rmargin 0.5
#set lmargin 2
#set bmargin 2
set multiplot layout 4,3 title ""
do for [i=1:words(par)] {
set label 1 sprintf("(%s) %s", word(labels, i), word(par, i)) at 1.5, 4 #labelFONT
plot for [f in file_tmpls] sprintf(f, word(par, i)) using 1:2 w l
}
unset multiplot
I need to contruct a figure with at least 12 plots in gnuplot epslatex terminal.
The problem is when number of plots becomes larger, the size of legend box becomes larger and it gets overlapped with the plots. How can I control the font size inside a legend box and also the size and positioning of the legend box? My gnuplot script is as below. After compilation of script file , the tex file which is produced could not be compiled.Please advise.
Gnuplot script:
reset
set terminal epslatex color colortext size 11cm,7.5cm standalone
set output "obspI=12.tex"
set style data lines
set multiplot
set log
set key samplen 1 left bottom
set key at 0.02,0.005
set key box lt 1 lc -2 lw 3
set xlabel "$t/N$"
set ylabel '$P_\ell(t)$'
set format y '$10^{%L}$'
set format x '$10^{%L}$'
set xr [0.01:1000]
set yr [0.002:1.5]
plot 'sp_e21_N20I1.dat' u 1:2 w l title '\footnotesize $\ell=1,N=20,E=21$' lc 7 lw 2, \
'sp_e19_N20I1.dat' u 1:2 w l title '\footnotesize $\ell=1,N=20,E=19$' lc 1 lw 2, \
'sp_n_N20I1.dat' u 1:2 w l title '\footnotesize $\ell=1,N=20$', \
'sp_e21_N20I10.dat' u 1:2 w l title '\footnotesize $\ell=10,N=20,E=21$' lw 2, \
'sp_e19_N20I10.dat' u 1:2 w l title '\footnotesize $\ell=10,N=20,E=19$' lw 2, \
'sp_n_N20I10.dat' u 1:2 w l title '\footnotesize $\ell=10,N=20$' lw 2, \
'sp_e21_N40I1.dat' u 1:2 w l title '\footnotesize $\ell=1,N=40,E=21$' lw 2, \
'sp_e19_N40I1.dat' u 1:2 w l title '\footnotesize $\ell=1,N=40,E=19$' lw 2, \
'sp_n_N40I1.dat' u 1:2 w l title '\footnotesize $\ell=1,N=40$', \
'sp_e21_N40I20.dat' u 1:2 w l title '\footnotesize $\ell=20,N=40,E=21$' lw 2, \
'sp_e19_N40I20.dat' u 1:2 w l title '\footnotesize $\ell=20,N=40,E=19$' lw 2, \
'sp_n_N40I20.dat' u 1:2 w l title '\footnotesize $\ell=20,N=40$' lw 2
unset multiplot
set output
The key text size (with or without a box) can be controlled by
set key font ",FONT_SIZE"
(where FONT_SIZE can be 10.5 for example).
For positioning the key box, see
here. There are plenty of options; you can position the key outside the main figure using, e.g.,
set key outside
Height and width of the key box can be controlled by "height" and "width", e.g.:
set key width -12
Hope that helped.