Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
835 views
in Technique[技术] by (71.8m points)

histogram - gnuplot, break y-axis in two parts

I have a histogram with some small values and some very big values. How can I break the y-axis in two parts?

EDIT:

enter image description here

gnuplot sample:

set style histogram columnstacked 
set style data histograms
set key autotitle columnheader
plot for [i=2:6] 'test.dat' using i

test.dat:

action device1 device2 device3
load    200 203 190 2 4
process 3 9 6 7 3
save    4 2 7 4 3
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

My answer is based on the example and comment on this website. In essence, you are looking for a broken y-axis, which can be achieved using the multiplot option:

reset
unset key
bm = 0.15
lm = 0.12
rm = 0.95
gap = 0.03
size = 0.75
kk = 0.5 # relative height of bottom plot
y1 = 0.0; y2 = 15.0; y3 = 180.0; y4 = 220.0

set style histogram columnstacked 
set style data histograms
set key autotitle columnheader
set style fill solid 1.0 border -1

set multiplot
set border 1+2+8
set xtics nomirror
set ytics nomirror
set lmargin at screen lm
set rmargin at screen rm
set bmargin at screen bm
set tmargin at screen bm + size * kk

set yrange [y1:y2]
plot for [i=2:6] 'test.dat' using i

unset xtics
unset xlabel
set border 2+4+8
set bmargin at screen bm + size * kk + gap
set tmargin at screen bm + size + gap
set yrange [y3:y4]

plot for [i=2:6] 'test.dat' using i

unset multiplot

Remarks:

  • The first block of code specifies your plot size, as well as the two min/max for the y-axis range.
  • The second block of code sets your histogram style. I suggest you used filled columns (else, you might get the wrong colors where the plot is cut off by the y-range).
  • The third block starts you multiplot environment and sets up the lower plot (4th block).
  • The fifth block of code defines you upper plot.
  • To customize your plot, change the parameters in the first block (bm, lm, rm, gap, size, kk and yi)

And this is the result:

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...