multiplot comparison

The FAMAlab investigates the electronic properties of pure and doped materials as well as adsorbed molecules on material surfaces. So making comparisons between different plots is very common. Here we are going to show different styles of comparison graphics. These plots are the most difficult ones to generate because they have to be very explicity and good distributed. Here are some tricks we have learn. To get a deep understanding please try to analize the templates and refered to the gnuplot manual.

We are going to use the same file as in the projected DOS to generate different plots.

Plots in the same row

- First we have to think on how our plots are goint to be distributed in relation with the number of plots we want to show. Then we have to split our canvas into the parts of the plots, for example if I want two plots on a row, I will use the 35% of the width per plot and the 90% fot the height as shown below. The rest of the canvas is used for space between the canvas and the plots and both of plots.

- Use the multiplot tool to put more tha one graphic on the same canvas. You have to define the size and the possition of each plot.

# Canvas size and initial position variables
#===========================================
xsize= 0.35   # Plot width in relation with canvas
ysize= 0.90   # Plot height in relation with canvas
xinit= 0.10   # The starting possition of the first plot
sum= 0.10     # Controls the separation between plots

# Settings of multiplot and global properties
#============================================
# What appears in this section will be repeated in each plot

set multiplot layout 1,2 columnfirst title ""   # 1 row with 2 columns
set  xlabel "Energy [eV]"
set  ylabel "Density of States [states/eV]"
set key at  0.3, 19 nobox         # Location of the label box
set xr [-8:4]                     # x ranges of both plots 
set yr [-20:20]                   # y ranges of both plots 

# First plot 
#=======================================
         # Reset keys
         unset rmargin
         unset lmargin
         # Set individual keys
         set size xsize, ysize            # Plot size in relation with canvas
         set lmargin at screen  xinit           # x inital possition 0.10
         set rmargin at screen  xinit + xsize   # x final possition 0.45 
         set label TiO_{2}" at -7, -15

         plot "DOS0.dat"   using 1:2 title "Total DOS" with lines ls 5 , \
              "DOS0.dat"   using 1:3 title "" with lines ls 5, \
              "ti_dos.dat" using 1:6 title "Ti (d)" with lines ls 10, \
              "ti_dos.dat" using 1:7 title "" with lines ls 10, \
              "o_dos.dat"  using 1:4 title "O (p)" with lines ls 11, \
              "o_dos.dat"  using 1:5 title "" with lines ls 11;

# Second plot 
#=======================================
         # Reset keys
         unset rmargin   # Clears the past x possition
         unset lmargin
         unset label     # Clears the past label
         # Set individual keys
         set size xsize, ysize            # Plot size in relation with canvas
         set lmargin at screen  xinit+xsize+sum   # x inital possition 0.55
         set rmargin at screen  1 - xinit         # x final possition 0.90 
         set label TiO_{2}_Pd" at -7, -15

         plot "DOS0.dat"   using 1:2 title "Total DOS" with lines ls 5 , \
              "DOS0.dat"   using 1:3 title "" with lines ls 5, \
              "ti_dos.dat" using 1:6 title "Ti (d)" with lines ls 10, \
              "ti_dos.dat" using 1:7 title "" with lines ls 10, \
              "o_dos.dat"  using 1:4 title "O (p)" with lines ls 11, \
              "o_dos.dat"  using 1:5 title "" with lines ls 11;

- Here lmargin and rmargin controls where to put every plot, and as they have different possitions in relation with the canvas you have to unset and re-set at every new plot. For instance here first plot starts at 0.10 and ends at 0.45 then the second plot starts at 0.55 and ends at 0.90.

- Download the template: row_multiplot.p

Merging plots with the same scale

- Lets repeat the las plot but ereasing the ytics and ylabel in the middle.

- Now the first plot most end where the second start. We have to delete the ytics and the ylabel from the second plot and merge the xtic of both.

# Canvas size and initial position variables
#===========================================
xsize= 0.40   # Plot width in relation with canvas
ysize= 0.90   # Plot height in relation with canvas
xinit= 0.10   # The starting possition of the first plot

# Settings of multiplot and global properties
#============================================
# What appears in this section will be repeated in each plot

set multiplot layout 1,2 columnfirst title ""   # 1 row with 2 columns
set  xlabel "Energy [eV]"
set  ylabel "Density of States [states/eV]"
set key at  0.3, 19 nobox         # Location of the label box
set xr [-8:4]                     # x ranges of both plots 
set yr [-20:20]                   # y ranges of both plots 

# First plot 
#=======================================
         # Reset keys
         unset rmargin
         unset lmargin
         # Set individual keys
         set size xsize, ysize            # Plot size in relation with canvas
         set lmargin at screen  xinit           # x inital possition 0.10
         set rmargin at screen  xinit + xsize   # x final possition 0.50 
         set label TiO_{2}" at -7, -15
         set  xlabel "Energy [eV]" offset 14,0   # Displace xlabel to the center of canvas
         set  ylabel "Density of States [states/eV]"

         plot "DOS0.dat"   using 1:2 title "Total DOS" with lines ls 5 , \
              "DOS0.dat"   using 1:3 title "" with lines ls 5, \
              "ti_dos.dat" using 1:6 title "Ti (d)" with lines ls 10, \
              "ti_dos.dat" using 1:7 title "" with lines ls 10, \
              "o_dos.dat"  using 1:4 title "O (p)" with lines ls 11, \
              "o_dos.dat"  using 1:5 title "" with lines ls 11;

# Second plot 
#=======================================
         # Reset keys
         unset rmargin   # Clears the past x possition
         unset lmargin
         unset label     # Clears the past label
         unset ytics     # Removes the y axis tics
         unset ylabel    # Removes the y axis label
         # Set individual keys
         set size xsize, ysize            # Plot size in relation with canvas
         set lmargin at screen  xinit+xsize     # x inital possition 0.50
         set rmargin at screen  1 - xinit         # x final possition 0.90 
         set label TiO_{2}_Pd" at -7, -15

         # TRICK Displace x axis label outside the canvas
         # but maintains the label space to be align
         set  xlabel "Energy [eV]" offset 50,0


         plot "DOS0.dat"   using 1:2 title "Total DOS" with lines ls 5 , \
              "DOS0.dat"   using 1:3 title "" with lines ls 5, \
              "ti_dos.dat" using 1:6 title "Ti (d)" with lines ls 10, \
              "ti_dos.dat" using 1:7 title "" with lines ls 10, \
              "o_dos.dat"  using 1:4 title "O (p)" with lines ls 11, \
              "o_dos.dat"  using 1:5 title "" with lines ls 11;

- Offset serves to move the axis label to a different possition. Here the x axis label of the first plot moves to 14 points to the right and gets in the middle. The second x axis label moves outside the canvas so it can not be shown, but gnuplot leaves the space that correspond to the label, so the second plot is aling with the first.

- Download the template: row_multiplot_nospace.p

PLOTS IN THE SAME COLUMN

- This case is similar to plot in rows. Now we are goint to use all canvas width, and divide the height, by the number of plots we want to put. In this example we are going to plot three plots on the same canvas.

- As we have said, we have to organize first our canvas, in this case we are leaving a 0.1 of canvas heigth as separation between plots to ensure labels fit. That will leave us only with 0.6 of canvas weith that divided on 3 give us 0.20 of canvas per plot.

# Canvas size and initial position variables
#===========================================
xsize= 0.95   # Plot width in relation with canvas
ysize= 0.20   # Plot height in relation with canvas

# Settings of multiplot and global properties
#============================================
# What appears in this section will be repeated in each plot

set multiplot layout 1,2 columnfirst title "Comparisson between curves"   # 1 row with 2 columns
set  xlabel "Energy [eV]"
set  ylabel "DOS [states/eV]"
set key at  0.3, 19 nobox         # Location of the label box
set xr [-8:4]                     # x ranges of both plots 
set yr [-20:20]                   # y ranges of both plots 

# First plot 
#=======================================
         # Reset keys
         unset tmargin  # Top margin 
         unset bmargin  # Bottom margin
         # Set individual keys
         set size xsize, ysize            # Plot size in relation with canvas
         set tmargin at screen  0.30      # y final  possition 0.30
         set bmargin at screen  0.10      # y initial possition 0.10 
         set label TiO_{2}" at -7, -15

         plot "DOS0.dat"   using 1:2 title "Total DOS" with lines ls 5 , \
              "DOS0.dat"   using 1:3 title "" with lines ls 5, \
              "ti_dos.dat" using 1:6 title "Ti (d)" with lines ls 10, \
              "ti_dos.dat" using 1:7 title "" with lines ls 10, \
              "o_dos.dat"  using 1:4 title "O (p)" with lines ls 11, \
              "o_dos.dat"  using 1:5 title "" with lines ls 11;

# Second plot 
#=======================================
         # Reset keys
         unset tmargin  # Top margin 
         unset bmargin  # Bottom margin
         unset label
         # Set individual keys
         set size xsize, ysize            # Plot size in relation with canvas
         set tmargin at screen  0.60      # y final  possition 0.60
         set bmargin at screen  0.40      # y initial possition 0.40 
         set label TiO_{2} Pd" at -7, -15

         plot "DOS0.dat"   using 1:2 title "Total DOS" with lines ls 5 , \
              "DOS0.dat"   using 1:3 title "" with lines ls 5, \
              "ti_dos.dat" using 1:6 title "Ti (d)" with lines ls 10, \
              "ti_dos.dat" using 1:7 title "" with lines ls 10, \
              "o_dos.dat"  using 1:4 title "O (p)" with lines ls 11, \
              "o_dos.dat"  using 1:5 title "" with lines ls 11;

# Third plot 
#=======================================
         # Reset keys
         unset tmargin  # Top margin 
         unset bmargin  # Bottom margin
         unset label
         # Set individual keys
         set size xsize, ysize            # Plot size in relation with canvas
         set tmargin at screen  0.90      # y final  possition 0.90
         set bmargin at screen  0.70      # y initial possition 0.70 
         set label TiO_{2} Xe" at -7, -15

         plot "DOS0.dat"   using 1:2 title "Total DOS" with lines ls 5 , \
              "DOS0.dat"   using 1:3 title "" with lines ls 5, \
              "ti_dos.dat" using 1:6 title "Ti (d)" with lines ls 10, \
              "ti_dos.dat" using 1:7 title "" with lines ls 10, \
              "o_dos.dat"  using 1:4 title "O (p)" with lines ls 11, \
              "o_dos.dat"  using 1:5 title "" with lines ls 11;

- Download the template: col_multiplot.p

Merge plots in a column

-Lets merge the plots deleting the space between them. We have to unset x axis tics and x axis label of the second and third plot. As we do in merging plots in rows, we have to align them setting the y axis label but plotting the label outside canvas.

# Canvas size and initial position variables
#===========================================
xsize= 0.95   # Plot width in relation with canvas
ysize= 0.265   # Plot height in relation with canvas
xinit= 0.10   # The starting possition of the first plot

# Settings of multiplot and global properties
#============================================
# What appears in this section will be repeated in each plot

set multiplot layout 3,1 columnfirst title "Comparisson Between Curves"   # 1 row with 2 columns
set key at  0.3, 19 nobox         # Location of the label box
set xr [-8:4]                     # x ranges of both plots 
set yr [-20:20]                   # y ranges of both plots 

# First plot 
#=======================================
         # Reset keys
         unset rmargin
         unset lmargin
         # Set individual keys
         set size xsize, ysize            # Plot size in relation with canvas
         set tmargin at screen  0.365           # y final possition 0.365
         set bmargin at screen  0.10            # y initial possition 0.10 
         set label TiO_{2}" at -7, -15
         set  xlabel "Energy [eV]"
         # Displace ylabel to the center of y axis
         set  ylabel "DOS [states/eV]" offset 0,15 

         plot "DOS0.dat"   using 1:2 title "Total DOS" with lines ls 5 , \
              "DOS0.dat"   using 1:3 title "" with lines ls 5, \
              "ti_dos.dat" using 1:6 title "Ti (d)" with lines ls 10, \
              "ti_dos.dat" using 1:7 title "" with lines ls 10, \
              "o_dos.dat"  using 1:4 title "O (p)" with lines ls 11, \
              "o_dos.dat"  using 1:5 title "" with lines ls 11;

# Second plot 
#=======================================
         # Reset keys
         unset tmargin   # Clears the past x possition
         unset bmargin
         unset label     # Clears the past label
         unset xtics     # Removes the x axis tics
         unset xlabel    # Removes the x axis label
         # Set individual keys
         set size xsize, ysize            # Plot size in relation with canvas
         set tmargin at screen  0.63    # y final possition 0.63
         set bmargin at screen  0.365   # y initial possition 0.365 
         set label TiO_{2}_Pd" at -7, -15

         # TRICK Displace y axis label outside the canvas
         # but maintains the label space to be align
         set  ylabel "DOS [states/eV]" offset 0,150


         plot "DOS0.dat"   using 1:2 title "Total DOS" with lines ls 5 , \
              "DOS0.dat"   using 1:3 title "" with lines ls 5, \
              "ti_dos.dat" using 1:6 title "Ti (d)" with lines ls 10, \
              "ti_dos.dat" using 1:7 title "" with lines ls 10, \
              "o_dos.dat"  using 1:4 title "O (p)" with lines ls 11, \
              "o_dos.dat"  using 1:5 title "" with lines ls 11;

# Third plot 
#=======================================
         # Reset keys
         unset tmargin   # Clears the past x possition
         unset bmargin
         unset label     # Clears the past label
         unset xtics     # Removes the x axis tics
         unset xlabel    # Removes the x axis label
         # Set individual keys
         set size xsize, ysize            # Plot size in relation with canvas
         set tmargin at screen  0.895   # y final possition 0.63
         set bmargin at screen  0.630   # y initial possition 0.365 
         set label TiO_{2}_Xe" at -7, -15

         # TRICK Displace y axis label outside the canvas
         # but maintains the label space to be align
         set  ylabel "DOS [states/eV]" offset 0,150


         plot "DOS0.dat"   using 1:2 title "Total DOS" with lines ls 5 , \
              "DOS0.dat"   using 1:3 title "" with lines ls 5, \
              "ti_dos.dat" using 1:6 title "Ti (d)" with lines ls 10, \
              "ti_dos.dat" using 1:7 title "" with lines ls 10, \
              "o_dos.dat"  using 1:4 title "O (p)" with lines ls 11, \
              "o_dos.dat"  using 1:5 title "" with lines ls 11;

- Download the template: col_multiplot.p_nospace.p