I am using gnuplot version 4.4 patchlevel 0 packaged by Debian on Linux.
If I combine the use of "smooth frequency" with "set logscale y", then the smooth frequency part is ignored. For example:
gnuplot> plot 'data' using 1:(1.0) smooth frequency
This plots a graph of value 1 on the x axis with its frequency on the y axis.
gnuplot> set logscale y
gnuplot> replot
Warning: empty y range [1:1], adjusting to [0.99:1.01]
However, this gives the above error message and plots a straight horizontal line with y value 1.0.
It is clear why the error message occurs. The "smooth frequency" bit is not ignored, it is applied exactly as requested. For each instance of an x value, log of (1.0) is added to the running total. But the log of (1.0) is 0, so all accumulated totals are also 0 and the y range is necessarily 0. Hence the error message.
It's less clear why the resulting plot draws a horizontal line at 1 rather than at 0, but I think that's because the program knows that a log scale axis can never reach, or span, 0. So it introduces an offset.
Requesting instead
plot 'data' using 1:(exp(1.0)) smooth frequency
may or may not be what you actually intended. That produces a plot with the correct shape, but again there is a vertical offset introduced. That is arguably a bug, but it's still true that a log scale axis cannot extend to zero it's hard to say what a better alternative would be.
What were you expecting to happen?
On Fri, 19 Jul 2013, Ethan Merritt wrote:
I see. Should gnuplot apply the log after doing the smooth, rather than
before it?
No, that's obvious. The logged values all sum to 0, which maps to 1 on the
scale.
No, it doesn't produce a plot with the correct shape. What it does is
produce a graph with the same shape as if "set logscale y" is not set, but
with different values on the scale.
Actually, no, what it does with my data is print an error message saying:
y axis range undefined or overflow
because gnuplot sums together a whole load of log(exp(1.0)) values, gets a
reasonable number, defines the (logscale) y range, and then tries to
convert those numbers to the logscale by calling exp() on them, which
understandably fails due to overflow.
I was expecting the y axis to be converted to log scale, and the
corresponding calculated "smooth frequency" values applied to that scale.
In other words, the logscale should be applied after the smooth, not
before.
Matthew
The way log scaling works in gnuplot is that the y value is converted to log(y) at the time the data is read in. In other words, by the time any of the analysis or plotting routines see it, it has already been logged. I think that was a poor choice, but the design goes back to code written more than 25 years ago.
The development version of gnuplot includes a start at an alternative approach to defining non-linear axes, e.g. "set link x2 via f(x)", but so far it is not complete enough to entirely replace the current log-scale mechanism.
Anyhow, I can think of one way to achieve what you want using an intermediate file.
Is that a satisfactory solution?
In 5.1 log scale is now handled differently, such that smoothing is done on the original data values rather than on the logged data values. The result is then shown on a log scale.
There may still be combinations of smooth + log that don't produce the expected/inteded result, but if so they are different cases than before.
Closing this as
5.1 - out of date
5.0 - won't fix