使用带有多个y轴的gnuplot的直方图 [英] Histogram using gnuplot with multiple y-axes
问题描述
我无法找到所面临的以下问题的解决方案.关于多轴的所有SO问题都涉及线图,但是我正在寻找直方图.
I could not find a solution to the following issue I am facing. All SO questions on multi-axis talk about line plots, but I am looking for histograms.
条形图的y-range
不同,因此由于比例尺的缘故,实际上并没有看到一组条形图.数据如下:
The y-range
for the bars are different, so one set of bars are not really seen because of the scale. Here is the data:
Metric A B
M1 0.613416301 0.543734744
M2 0.000195961 0.000100190
这是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
这是示例输出(看不到M2上的一组条形图):
This is the sample output (one set of bars over M2 is not seen):
我更希望有第二个y轴(位于图的右侧),其范围适合于我的数据文件的第二行.这可能吗?任何帮助,我们将不胜感激.
What I prefer is to have a second y-axis (to the right side of the plot) with a range appropriate to the second row of my data file. Is this possible? Any help is greatly appreciated.
推荐答案
通常,您可以使用newhistogram
在彼此下方绘制重度直方图.但是,当使用模式作为fillstyle时,这似乎有问题:
Normally you can plot severyl histograms beneath each other using newhistogram
. However, it seems like this is buggy when using patterns 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
或者,您可以使用multiplot
并将两个直方图绘制在彼此的正下方:
Alternatively you can use multiplot
and plot the two histograms directly beneath 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
如果您不希望使用黑色分隔线,则可以将set border 7
用作第一个图,将set border 13
用作第二个图.
If you don't want the separating black line, you can use set border 7
for the first and set border 13
for the second plot.
这篇关于使用带有多个y轴的gnuplot的直方图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!