0
votes

My test.dat file looks like

# Experiment No.  Total U_Na-Z (millimoles/g of zeolite) Total Na_Na-Z in melt (mmoles/g zeolite)         Total U_Li-Z (millimoles/g of zeolite) Total Na_Li-Z in melt (mmoles/g zeolite)
Experiment No.  Total U loading (mmoles/g zeolite)   Total Na in melt (mmoles/g of zeolite)           Total U loading (mmoles/g zeolite)   Total Na in melt (mmoles/g of zeolite) 
1                0.074798319                          4.60                                              0.061795848                          1.38
2                0.148512605                          3.73                                              0.122910867                          1.72
3                0.223310924                          4.02                                              0.216806723                          1.46
4                0.287268908                          5.26                                              0.275399753                          1.60               

I would like to plot a histogram with two y axis (Col 2 as y and Col 3 as y2) against Col 1 (x-axis), and in the same histogram, Col 4 (as y) and Col 5 (as y2) has to be plotted against Col 1, of course with different colours. Script is given below (newhistogram script from gnuplot accordingly modified)

set terminal postscript eps enhanced colour font 'Times-Roman,12' size 5in,4in  
set output "Histogram1.eps"
#------------------------------------------------------------------------------
set style line 1 lt 2 lw 1 lc rgb "#000FF"
set style line 2 lt 3 lw 1 lc rgb "#228B22"
set style line 3 lt 4 lw 1 lc rgb "#FF4500"
set style line 4 lt 5 lw 1 lc rgb "#8B0000"
set style line 5 lt 6 lw 1 lc rgb "dark-magenta"
#------------------------------------------------------------------------------
set xtics out scale 1.5 
set ytics out scale 1.5
set y2tics out scale 1.5 
set ytics nomirror
set yrange [0:0.50]
set y2range [0:6] 
set key off
set tics font ", 14"
set xlabel "Experiment No." font ",16"
set ylabel "U loading in zeolite (mmoles/g zeolite)" font ",16"
set y2label "Na in melt (mmoles/g zeolite)" 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
# ----------------------------------------

Now the plot command was given as

plot \
newhistogram "Sodium Zeolite", \
'test.dat' using 2:xtic(1) ls 1 ti col axis x1y1, '' 3:xticlabels(1) ls 2 ti col axis x1y2, \
newhistogram "Lithium Zeolite", \
'' using 4:xtic(1) ls 3 ti col axis x1y1, '' 5:xticlabels(1) ls 4 ti col axis x1y2 

In the x-axis, for the first four data, "Sodium Zeolite" has to be shown and for the nest four, "Lithium Zeolite" has to be shown. But it does not seem to work. Any suggestions would be of help.

Thank you,

1

1 Answers

2
votes

Several minor issues:

  • You need to tell the program to use the histogram plot style. The best way is to add a line before the plot command:

    set style data histogram

  • the keyword is axes, not axis.

  • the using keyword must be present in every plot clause

  • it is not necessary to give the xticlabels(1) command more than once per plot (though it should not hurt either, but the labels will be printed twice in the same place).

This gives a modified plot command:

set style data histogram
plot \
  newhistogram "Sodium Zeolite", \
  'test.dat' using 2:xtic(1) ls 1 ti col axes x1y1, \
  '' using 3 ls 2 ti col axes x1y2, \
  newhistogram "Lithium Zeolite", \
  '' using 4:xtic(1) ls 3 ti col axes x1y1, \
  '' using 5 ls 4 ti col axes x1y2

with output as shown enter image description here