Blaisem
Blaisem

Reputation: 637

gnuplot coordinating portions of multiple input files into 2 stacked graphs

I'm trying the multiplot function for the first time, and as I read on another question here, replot doesn't seem well suited here, but I don't understand gnuplot well enough to pursue alternatives.

I have two plots with 2 input files each. The first plot requires selecting data differently for each input file (hence replot). I would like to arrange these two plots stacked in 2 rows, 1 column.

If I remove the input for either graph, I can plot them individually just fine, so the syntax is correct at least to that extent.

Here is my input:

se te po enh co so
se ou "plot_tfoh-2.ipdip"
set xrange[10:50]
set xlabel "{/ -Bold ionization energy [eV]}"
set ylabel "{/ -Bold spectral intensity}" offset 1.25,0
set tics out
set xtics nomirror
set ytics nomirror
set title "{/ -Bold tfoh-2 | Ionization Spectra}" offset 0,-0.5
#FIRST GRAPH (top graph in multiplot)
plot 0 notitle
replot "//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.2.dat" u 2:(+$11*$11+$10*$10+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "orb 25" w i lt 25
replot "//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.1.dat" u 2:(+$20*$20+$19*$19+$18*$18+$17*$17+$16*$16+$15*$15+$14*$14+$13*$13+$12*$12+$11*$11+$10*$10+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "orb 24" w i lt 24
replot "//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.1.dat" u 2:(+$19*$19+$18*$18+$17*$17+$16*$16+$15*$15+$14*$14+$13*$13+$12*$12+$11*$11+$10*$10+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "orb 23" w i lt 23
replot "//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.2.dat" u 2:(+$10*$10+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "orb 22" w i lt 22
replot "//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.2.dat" u 2:(+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "F{/Arial \"}_{py} - F{/Arial '}_{py}" w i lt 21
replot "//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.1.dat" u 2:(+$18*$18+$17*$17+$16*$16+$15*$15+$14*$14+$13*$13+$12*$12+$11*$11+$10*$10+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "F{/Arial \"}_{py} - F{/Arial '}_{pz}" w i lt 20
replot "//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.2.dat" u 2:(+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "orb 19" w i lt 19
replot "//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.1.dat" u 2:(+$17*$17+$16*$16+$15*$15+$14*$14+$13*$13+$12*$12+$11*$11+$10*$10+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "(O-F)_p" w i lt 18
replot "//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.2.dat" u 2:(+$7*$7+$6*$6+$5*$5+$4*$4) t "orb 17" w i lt 17
replot "//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.1.dat" u 2:(+$16*$16+$15*$15+$14*$14+$13*$13+$12*$12+$11*$11+$10*$10+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "(O-F)_p" w i lt 16
replot "//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.1.dat" u 2:(+$15*$15+$14*$14+$13*$13+$12*$12+$11*$11+$10*$10+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "orb 15" w i lt 15
replot "//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.2.dat" u 2:(+$6*$6+$5*$5+$4*$4) t "orb 14" w i lt 14
replot "//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.1.dat" u 2:(+$14*$14+$13*$13+$12*$12+$11*$11+$10*$10+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "orb 13" w i lt 13
replot "//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.1.dat" u 2:(+$13*$13+$12*$12+$11*$11+$10*$10+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "orb 12" w i lt 12
replot "//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.1.dat" u 2:(+$12*$12+$11*$11+$10*$10+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "orb 11" w i lt 11
replot "//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.1.dat" u 2:(+$11*$11+$10*$10+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "O_{2s}" w i lt 10
replot "//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.2.dat" u 2:(+$5*$5+$4*$4) t "F{/Arial \"}_{2s}" w i lt 9
replot "//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.1.dat" u 2:(+$10*$10+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "(F{/Arial '} - F{/Arial \"})_{2s}" w i lt 8
replot "//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.1.dat" u 2:(+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "F_{2s}" w i lt 7
# SECOND GRAPH (bottom graph in multiplot)
plot 0 notitle
replot "//worka/blaise/masters/results/tfoh-2/dip/plot_tfoh-2.dip.input.dat" notitle w i lc rgb 'grey50'
replot "/worka/blaise/masters/results/tfoh-2/dip/final.replotConfig.dat" using 1:2 t "O-F 2h states" w i lc rgb "red"
se te po enh co so
set key top right font ",13"
se ou "ref.plot_tfoh-2.ipdip.ps"
replot

I would very much appreciate any help on the matter. If I can add any more details, please let me know.

Upvotes: 0

Views: 48

Answers (1)

Vinicius Placco
Vinicius Placco

Reputation: 1731

You need to set the multiplot environment before plotting. Based on your example, it would look similar to the following:

se te po enh co so
se ou "plot_tfoh-2.ipdip.ps"
set xrange[10:50]
set xlabel "{/ -Bold ionization energy [eV]}"
set ylabel "{/ -Bold spectral intensity}" offset 1.25,0
set tics out
set xtics nomirror
set ytics nomirror
set title "{/ -Bold tfoh-2 | Ionization Spectra}" offset 0,-0.5

set multiplot layout 2,1

#FIRST GRAPH (top graph in multiplot)
plot 0 notitle,\
"//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.2.dat" u 2:(+$11*$11+$10*$10+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "orb 25" w i lt 25,\
"//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.1.dat" u 2:(+$20*$20+$19*$19+$18*$18+$17*$17+$16*$16+$15*$15+$14*$14+$13*$13+$12*$12+$11*$11+$10*$10+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "orb 24" w i lt 24,\
"//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.1.dat" u 2:(+$19*$19+$18*$18+$17*$17+$16*$16+$15*$15+$14*$14+$13*$13+$12*$12+$11*$11+$10*$10+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "orb 23" w i lt 23,\
"//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.2.dat" u 2:(+$10*$10+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "orb 22" w i lt 22,\
"//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.2.dat" u 2:(+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "F{/Arial \"}_{py} - F{/Arial '}_{py}" w i lt 21,\
"//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.1.dat" u 2:(+$18*$18+$17*$17+$16*$16+$15*$15+$14*$14+$13*$13+$12*$12+$11*$11+$10*$10+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "F{/Arial \"}_{py} - F{/Arial '}_{pz}" w i lt 20,\
"//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.2.dat" u 2:(+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "orb 19" w i lt 19,\
"//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.1.dat" u 2:(+$17*$17+$16*$16+$15*$15+$14*$14+$13*$13+$12*$12+$11*$11+$10*$10+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "(O-F)_p" w i lt 18,\
"//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.2.dat" u 2:(+$7*$7+$6*$6+$5*$5+$4*$4) t "orb 17" w i lt 17,\
"//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.1.dat" u 2:(+$16*$16+$15*$15+$14*$14+$13*$13+$12*$12+$11*$11+$10*$10+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "(O-F)_p" w i lt 16,\
"//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.1.dat" u 2:(+$15*$15+$14*$14+$13*$13+$12*$12+$11*$11+$10*$10+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "orb 15" w i lt 15,\
"//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.2.dat" u 2:(+$6*$6+$5*$5+$4*$4) t "orb 14" w i lt 14,\
"//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.1.dat" u 2:(+$14*$14+$13*$13+$12*$12+$11*$11+$10*$10+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "orb 13" w i lt 13,\
"//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.1.dat" u 2:(+$13*$13+$12*$12+$11*$11+$10*$10+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "orb 12" w i lt 12,\
"//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.1.dat" u 2:(+$12*$12+$11*$11+$10*$10+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "orb 11" w i lt 11,\
"//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.1.dat" u 2:(+$11*$11+$10*$10+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "O_{2s}" w i lt 10,\
"//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.2.dat" u 2:(+$5*$5+$4*$4) t "F{/Arial \"}_{2s}" w i lt 9,\
"//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.1.dat" u 2:(+$10*$10+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "(F{/Arial '} - F{/Arial \"})_{2s}" w i lt 8,\
"//worka/blaise/masters/results/tfoh-2/ip/plot_tfoh-2.ip.1.dat" u 2:(+$9*$9+$8*$8+$7*$7+$6*$6+$5*$5+$4*$4) t "F_{2s}" w i lt 7


# SECOND GRAPH (bottom graph in multiplot)

plot 0 notitle,\
"//worka/blaise/masters/results/tfoh-2/dip/plot_tfoh-2.dip.input.dat" notitle w i lc rgb 'grey50',\
"/worka/blaise/masters/results/tfoh-2/dip/final.replotConfig.dat" using 1:2 t "O-F 2h states" w i lc rgb "red"

Note that there is no replot command, just commas separating the various components of each panel. Please refer to the documentation and demos for additional examples.

Hope this helps!

Upvotes: 1

Related Questions