I have a problem with autoscaling on the y2 axis. Please take a look at the following graphics ctrated by gnuplot:
http://userpages.uni-koblenz.de/~krienke/wetter/wetter.cgi?pl=RA0;sd=2003-10-27;ed=2003-10-27
You see that the left y axis has a different labeling than the right y2 axis. The labels on the left side are correct and
should also appear at the right side which always happens when the values displayed are *not all* equal to zero.
So if there is just one value != 0 than it is displayed and the labels on both axis (y and y2) are correct. Besides this
I hoped I
told gnuplot to use a range starting with 0, so no negative label should appear at the y axis but it does.
The gnuplot file I used to create this graphics looks like this:
set xdata time
set autoscale
set size 1.1,1.1
# Be aware: There is a tab inside !!
set timefmt "%Y-%m-%d %H:%M:%S"
# Line style for data plot sensor1, sensor 2
set linestyle 1 lt 1 lw 1 pt 2 ps 0.5
# more linestyles
set key left # Legend is placed left
set key samplen 0 # Make sample line shorter than default
set xtics rotate
set ytics nomirror # do not mirror ytics on right side (=>y2tics)
set y2tics # labels at the right side as well
set mytics 5 # Count of minor tics on y axis
set my2tics 5 # Count of minor tics on y axis
set xrange ['2003-10-28 00:00:00':'2003-10-28 24:00:00']
set xlabel 'Datum' 0,-2
set ylabel 'Wert'
set output "/tmp/xxxx";
set terminal png small color xEAF0FF
set grid xtics ytics mytics lt 36, lt 0
set mxtics 2
set xtics '2003-10-28 00:00:00', 7200 ,'2003-10-28 24:00:00'
set format x "%d-%m-%y\n%H:%M"
set yrange [0:*]
set y2range [0:*]
plot "/tmp/s_0.12773" using 1:3 title 'Regen(l/m*m)' with impulses
The data file looks like this (here: all values are 0):
2003-10-28 00:05:01 0
2003-10-28 00:17:01 0
2003-10-28 00:29:01 0
2003-10-28 00:41:00 0
2003-10-28 00:53:00 0
2003-10-28 01:05:58 0
Any idea what might be wrong? I am using gnuplot-3.7.1-561 on a suse8.1-system.
Thanks
Rainer
--
---------------------------------------------------------------------------
Rainer Krienke, Universitaet Koblenz, Rechenzentrum, Raum A022
Universitaetsstrasse 1, 56070 Koblenz, Tel: +49 261287 -1312, Fax: -1001312
Mail: kri...@uni-koblenz.de, Web: http://www.uni-koblenz.de/~krienke
Get my public PGP key: http://www.uni-koblenz.de/~krienke/mypgp.html
---------------------------------------------------------------------------
> You see that the left y axis has a different labeling than the right
> y2 axis. The labels on the left side are correct and should also
> appear at the right side which always happens when the values
> displayed are *not all* equal to zero. So if there is just one
> value != 0 than it is displayed and the labels on both axis (y and
> y2) are correct.
If *all* your y values are zero, on an autoscaled axis, you should
have gotten a warning messages printed out by gnuplot, complaining
about this fact ('empty y range --- adjusting to...').
You just exhibited one of the reasons for that warning.
This adjustment is *only* done for the axis you actually plot to.
Using 'y2tics' to generate tic labels on the "wrong" side of the
plot is not really recommended, and the case you outline is one
of those where it'll fail.
> Any idea what might be wrong? I am using gnuplot-3.7.1-561 on a
> suse8.1-system.
You may want to upgrade to gnuplot-3.7.3 then.
--
Hans-Bernhard Broeker (bro...@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
> Rainer Krienke <kri...@uni-koblenz.de> wrote:
>
>> You see that the left y axis has a different labeling than the right
>> y2 axis. The labels on the left side are correct and should also
>> appear at the right side which always happens when the values
>> displayed are *not all* equal to zero. So if there is just one
>> value != 0 than it is displayed and the labels on both axis (y and
>> y2) are correct.
>
> If *all* your y values are zero, on an autoscaled axis, you should
> have gotten a warning messages printed out by gnuplot, complaining
> about this fact ('empty y range --- adjusting to...').
>
> You just exhibited one of the reasons for that warning.
>
> This adjustment is *only* done for the axis you actually plot to.
> Using 'y2tics' to generate tic labels on the "wrong" side of the
> plot is not really recommended, and the case you outline is one
> of those where it'll fail.
Well in this case I do not understand why the labels are correct on both
sides if there are non zero values? If using y2tics is the wrong way to
get labels on the right y axis (as well as on the left y axis) is there a
better "recommended" way to do this?
> Well in this case I do not understand why the labels are correct on both
> sides if there are non zero values?
In a nutshell: you got lucky. Somebody decided that if y2tics have
been requested, but no y2 range exists to decide where to put them,
then the only sensible way to plot the y2tics at all would be to copy
the yrange to the y2range. But in some more intricate cases, that
hack is doomed to fail. Up to version 3.7.1, e.g., doing this with
log axes was an almost certain path to nonsense output.
> If using y2tics is the wrong way to get labels on the right y axis
> (as well as on the left y axis) is there a better "recommended" way
> to do this?
Y2tics are meant to be used primarily as an *independent* second y
axis, for plots with multiple incommensurable data sets in one graph.
Having them mirror the primary y axis ticks is a hack, not a designed
feature.
In the light of that, about the most robust recommendation would be to
actually do plot the dataset to the y2 axis, too, e.g.:
plot 'datafile' using 1:2, \
'' using 1:2 axes x1y2 with point pt -1