[GRASS-dev] d.histogram problem [bug #1977]
paul-grass at stjohnspoint.co.uk
Tue May 15 18:04:28 EDT 2007
On Tue, 15 May 2007, Paul Kelly wrote:
> On Tue, 15 May 2007, Hamish wrote:
>> ok, so bug #1977 still matters. (axes tags somewhat broken for FP maps)
> I wonder is there a bit more too it that just the axes labelling. E.g. I
> tried comparing the output of "r.stats -c input=slope nsteps=10" to what
> d.histogram draws for nsteps=10. r.stats says:
> 0-5.252012 81333
> 5.252012-10.504024 86135
> 10.504024-15.756036 60593
> 15.756036-21.008047 37301
> 21.008047-26.260059 16918
> 26.260059-31.512071 6275
> 31.512071-36.764083 1415
> 36.764083-42.016095 139
> 42.016095-47.268107 13
> 47.268107-52.520119 1
> * 12929
> i.e. it seems obvious the first bar should cover the range 0-5.25012 and so
> on (although I think it's fine that the x-axis label shows whole numbers; it
> doesn't need to line up with the bar/bin edges), but in the d.histogram
> output it seems quite clear that the first bar is drawn between 5 and 10
> (approximately) on the x-axis.
Actually, to put that another way you could say the numbers on the x-axis
are in completely the wrong places. To me, it seems the numbers shown
under the ticks refer to the floor'ed value (i.e. probably a double cast
to an int) of the maximum value included in the bin to the right of the
tickmark, if that makes sense. I.e. the numbers are one-off to the left
of the ticks they represent, but even if shown under the correct tick they
would still be wrong because they have been truncated to integers.
(Looking at the output of r.stats -c xxx nsteps=xx next to the histogram
plot is really helpful for understanding this.)
I think the ticks should have no relation to the position of the borders
between the bars. The left-hand edge of the first bar should start at the
minimum value of the data and the right hand edge of the last bar should
end at the maximum value of the data. I think round numbers in between
should be marked with ticks (spacing worked out somehow from the
hard-coded maximum 40 bins between numbered ticks).
That's probably easier to fix, than to put a more comprehensive fix in
that would do the binning within d.histogram rather than relying on
r.stats to do it all. Such a solution would enable the number of bins for
integer maps to be specified too. At present this really doesn't seem
possible without changing the structure of either d.histogram or r.stats.
> Also it seems strange that it doesn't allow you to set the number of bins for
> non-floating point maps.
> Also, 255 bins seems not a very good default to me. It is a bit high and the
> result doesn't really look like a histogram.
> I'll try and look into it more if I have time. Always remember doing maths at
> school and drawing a proper histogram being something that was really easy to
> get wrong!
> grass-dev mailing list
> grass-dev at grass.itc.it
More information about the grass-dev