1
votes

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?

1

1 Answers

1
votes

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

Graph