Histogram using gnuplot with multiple y-axes

I could not find a solution to the next problem I was facing. All SO questions are on multi-axis string talk, but I'm looking for histograms.

y-range

the bars are different, so one set of bars is not actually visible due to the scale. Here's the data:


Metric A B
M1 0.613416301 0.543734744 
M2 0.000195961 0.000100190

      

Here is the MWE:


reset
set term postscript eps size 5.5,4.5 enhanced color font 'Arial-Bold' 25
set out 'histplot.eps'
set key right 
set style histogram cluster gap 2 
set style data histograms
set style fill pattern 1.00 border
set y2range [0.0001:0.0002]
plot 'histplot.dat' using 2 ti col, '' u 3:xticlabels(1) ti col
quit

      

This is an example of output (one set of bars above M2 is not displayed): compare metrics

I prefer to have a second y-axis (on the right side of the plot) with a range corresponding to the second line of my data file. Is it possible? Any help is appreciated.

+3


source to share


1 answer


Typically, you can display gray histograms below each other using newhistogram

. However, this seems to be a bug when using templates as fillstyle:

reset
set style histogram cluster gap 1
set style data histograms
set style fill pattern 1.00 border

set yrange [0:*]
set ytics nomirror
set y2range [0:*]
set y2tics

set key right autotitle columnheader
plot 'histplot.dat' u 2 every ::::0, '' u 3:xtic(1) every ::::0,\
     newhistogram lt 1 at 1,\
     'histplot.dat' u 2 every ::1::1 axes x1y2, '' u 3:xtic(1) every ::1::1 axes x1y2

      

enter image description here

Alternatively, you can use multiplot

and plot two histograms directly below each other:



reset
set style histogram cluster gap 1
set style data histograms
set style fill pattern 1.00 border

set yrange [0:*]
set ytics nomirror
set multiplot layout 1,2
set rmargin at screen 0.5
set lmargin 9
unset key
plot 'histplot.dat' using 2 every ::::0 ti col, '' u 3:xticlabels(1) every ::::0 ti col

set rmargin 9
set lmargin at screen 0.5
unset ytics
set y2range [0:*]
set y2tics
set key right
plot '' using 2 every ::1::1 axes x1y2 ti col, '' u 3:xtic(1) every ::1::1 axes x1y2 ti col
unset multiplot

      

enter image description here

If you don't want black line selection, you can use set border 7

for the first and set border 13

for the second graph.

+5


source







All Articles