|
From: Ethan M. <merritt@u.washington.edu> - 2010-11-05 18:50:45
|
I have encountered a problem while trying to predict or adjust axis scaling
in advance of actually issuing a plot command. The problem is that the
"set log" command sets the field AXIS.base, but the corresponding field
log_base is not initialized until a subsequent plot command invokes the
macro AXIS_INIT2D. Instead it is set to zero.
So until you actually issue a plot command, anything that tries to use
the macros AXIS_DO_LOG or AXIS_UNDO_LOG triggers a
divide by zero or other error because AXIS.log_base is 0.
Why would you ever want to have AXIS.log_base out of sync with AXIS.base?
Why is it reset to zero in several places? Zero is never a correct value
to use in applying the log scale, and I don't see any place in the code
that uses zero/non-zero as a flag to control something else.
Can anyone think of a reason why it isn't correct to always set log_base
at the same time the base itself is set? I.e., on every call to "set log".
And everywhere that it is set to zero should be removed, since zero is
never a legal value. If an initialization value is needed, log(10) makes
a whole lot more sence than 0.
So, proposed patch:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--- gnuplot/src/set.c 2010-10-11 14:30:23.000000000 -0700
+++ gnuplot-new/src/set.c 2010-11-05 11:43:27.000000000 -0700
@@ -2229,6 +2229,7 @@ set_logscale()
if (set_for_axis[axis]) {
axis_array[axis].log = TRUE;
axis_array[axis].base = newbase;
+ axis_array[axis].log_base = log(newbase);
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Anyone see a problem with this?
Ethan
|