I can probably write GUI code to make a nice histogram, using output from
r.stats. But Glynn's point about having GRASS tools available for scripting
is well taken. Also, it's a lot easier to simply call d.histogram than to
manually write the code to create a histogram.
Since you folks are looking at the guts of d.histogram, I should point out
that primitive as it is, it can create a couple of statistical graphs
(histogram and pie graph based on internal binning calculations), a bar
graph (what the histogram is actually drawing), and a pie graph. If it can
draw a bar graph, it can probably draw a line graph and scatter plot with
little additional work.
This could make it a fairly comprehensive internal graphing utility, with
limited but useful statistical capabilities, that could be applied to a
variety of tasks (e.g., displays from r.regression, several image processing
functions).
I don't know if it is worth the effort or not, but maybe it is worth
thinking about for a few minutes at least.
Michael
On 5/15/07 3:04 PM, "Paul Kelly" <paul-grass@stjohnspoint.co.uk> wrote:
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)
http://intevation.de/rt/webrt?serial_num=1977
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.
Paul
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!
Paul
_______________________________________________
grass-dev mailing list
grass-dev@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass-dev
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University
phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton