[GRASSLIST:381] Re: Legends
H Bowman
hamish_nospam at yahoo.com
Sat Jun 14 01:55:29 EDT 2003
> * What's the status of 'legend' in NVIZ ? Any implementation yet ?
As I recall, it was being worked on in CVS:
grass/src.contrib/GMSL/NVIZ2.2/src/draw.c
v1.6 7 weeks bob Added functions for N arrow, colorbar, and labels
Looks like it's there.
> * When displaying the legend of a CELL map, *all* the categories are
> displayed, when in fact, one would be interested only in the
> categories really displayed. Actually, it's worse: if your categories
> are not continuous (eg 10,11,12,27), the legend reports *all* the
> categories from the smallest to the largest, when one would expect
> only the categories defined (in the previous example, I have 18 labels
> in my legend, when I only need 4).
Use d.legend's -n flag if you are using 5.0.1 or 5.0.2.
You could also try my new version with the use= option, which only
displays categories you select. e.g. use=10,11,12,27. I've been
meaning to put this in the 5.1 CVS, but haven't had the time lately to
put on the finishing touches.
http://bambi.otago.ac.nz/hamish/main.c.withUSE10
> * Now, the opposite problem:
> Is there a way to force GRASS to display a legend based on a given
> color table, even if some categories are missing ?
> For example, I have a FCELL map with values in the range 0-1000. The
> legend starts at the lowest category (say, 127) and ends at the
> largest (say, 851), when in fact, I expect a display from 0 to 1000.
> Here again, any work around ? (apart forcing one of the cells to 0,
> and another to 1000 ?) Could it be implemented for a next version ?
d.legend takes the color from the map. If the color doesn't exist in the
map, d.legend can't know what to use. I think it is a bad idea to have
d.legend try and extrapolate a color value or read directly from the
colr file and re-implement existing library functions. I suppose it
might be feasible to extend the default range with the range= option
with whatever library function the raster map uses to find its color
value if you wanted, but I have no plans to do so and don't think the
official version should do this either.
What you might do is create a second floating poing map with a range of
0.0-1000.0, then:
r.colors newmap rast=origmap
d.rast origmap
d.legend newmap -options...
Or use 'range=130,850 labelnum=5' (or labelnum=4) if you just want
prettier subdivision text.
hint: if you play with range and labelnum so (max-min)/(labelnum-1) is a
multiple of ten then the results will look ok... As this isn't exactly
user friendly I was playing with the idea of using ps.map's new f.p.
legend smarts. The results are quite nice, but it does remove some
control over what is drawn, so as of yet I am undecided.
Feedback is always welcomed.
Hamish
More information about the grass-user
mailing list