Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to adjust the automatic yaxis scale to provide headroom in bar chart

38 views
Skip to first unread message

thats.un...@gmail.com

unread,
Dec 11, 2015, 10:55:47 PM12/11/15
to
I'm using "gnuplot 5.0 patchlevel 1" and I noticed that when I plot a bar graph, sometimes the autoscale for the y-axis causes one of the bars to be jammed up against the top edge of the chart (with no headroom at all). This is not very visually appealing. Is there any way to tell the autoscale setting to leave a bit of headroom above the top data box?

Here's an example that exhibits the problem:

set terminal svg size 1024,768
set output "ottawa/svg/MAX_TEMP.top10.svg"
set xtics rotate 90 ("2015" 0, "1911" 1, "1879" 2, "1939" 3, "1953" 4, "1923" 5, "1948" 6, "1884" 7, "1932" 8, "1998" 9, "1951" 10) font "Arial,20"
set y2label "maximum temperature (^oC)"
unset ytics
set y2tics
set key on left
set title "Top 10 Ottawa daily maximum temperatures for Dec 07"
set lmargin 6.0
set rmargin 8.0
set tmargin 2.0
set bmargin 5.0
set xrange [-1:11]
set boxwidth 0.750000
set style fill solid 1.00 border -1
set grid noxtics front
plot '-' title 'Other years' axes x1y2 with boxes fc rgb "0x6495ED" fs solid 1.0 noborder, '-' title 'This year' axes x1y2 with boxes fc rgb "0x556B2F" fs solid 1.0 noborder
1 5.600000 # 1911
2 5.600000 # 1879
3 6.100000 # 1939
4 6.700000 # 1953
5 6.700000 # 1923
6 7.800000 # 1948
7 8.300000 # 1884
8 8.300000 # 1932
9 14.100000 # 1998
10 15.000000 # 1951
e
0 5.600000 # 2015
e

Hans-Bernhard Bröker

unread,
Dec 12, 2015, 10:27:40 AM12/12/15
to
Am 12.12.2015 um 04:55 schrieb thats.un...@gmail.com:

> I'm using "gnuplot 5.0 patchlevel 1" and I noticed that when I plot a
> bar graph, sometimes the autoscale for the y-axis causes one of the
> bars to be jammed up against the top edge of the chart (with no
> headroom at all). This is not very visually appealing. Is there any
> way to tell the autoscale setting to leave a bit of headroom above
> the top data box?

See "help set offset"

Rolf Campbell

unread,
Dec 12, 2015, 12:49:21 PM12/12/15
to
On Saturday, December 12, 2015 at 10:27:40 AM UTC-5, Hans-Bernhard Bröker wrote:
> Am 12.12.2015 um 04:55 schrieb thats.un...@gmail.com:
> See "help set offset"

I tried that, but "set offset" seems to do nothing with an x1y2 plot. I think it only works with x1y1.

Jörg Buchholz

unread,
Dec 15, 2015, 4:57:43 AM12/15/15
to
As a workaround you can plot first with the term unknown and than set
the y2range.

......
set term unknown
plot '-' title 'Other years' axes x1y2 with boxes fc rgb "0x6495ED" fs
solid 1.0 noborder, '-' title 'This year' axes x1y2 with boxes fc rgb
"0x556B2F" fs solid 1.0 noborder
1 5.600000 # 1911
2 5.600000 # 1879
3 6.100000 # 1939
4 6.700000 # 1953
5 6.700000 # 1923
6 7.800000 # 1948
7 8.300000 # 1884
8 8.300000 # 1932
9 14.100000 # 1998
10 15.000000 # 1951
e
0 5.600000 # 2015
e
y2o = GPVAL_Y2_MAX + 2.0
set y2range [*:y2o]
set terminal svg size 1024,768
set output "test.svg"
replot
set out

Jörg
0 new messages