[GRASS5] GRASS 5.3: d.legend font size problem

Hello,

I have a problem with the automatic adjustment of font size in d.legend.
Using frames, I created the following display:

http://moritz.homelinux.org/misc/good_legend.png

where everything displays fine. But when I try to reduce the width of the
frame containing the raster legend, I get the following result:

http://moritz.homelinux.org/misc/bad_legend.png

In an (old) thread
(http://thread.gmane.org/gmane.comp.gis.grass.devel/154) Hamish said "the
maxfontsize= functionality is somewhat unneeded now that font size will
auto-adjust if it is too large for the window", but this does not seem to
work in my case...

Any hints ?

Moritz

I have a problem with the automatic adjustment of font size in
d.legend. Using frames, I created the following display:

http://moritz.homelinux.org/misc/good_legend.png

where everything displays fine. But when I try to reduce the width of
the frame containing the raster legend, I get the following result:

http://moritz.homelinux.org/misc/bad_legend.png

In an (old) thread
(http://thread.gmane.org/gmane.comp.gis.grass.devel/154) Hamish said
"the maxfontsize= functionality is somewhat unneeded now that font
size will auto-adjust if it is too large for the window", but this
does not seem to work in my case...

Any hints ?

Auto-scaling text is only implemented for categorical legends.
I'll look into getting it working for gradient legends too.

Legend text is generally controlled by the height of the legend box.

Another option is to use the use= option. :wink: This will make a category
legend & thus auto-scale the text. From the look of your map, this may
be suited to your data..

BTW, have you tried the new horizontal legends? Maybe that is more
appropriate for your map?

Also, your "good" legend seems to have some label cruft ")" in it;
try using the -v flag.

I also see one of the recent d.frame fixes isn't drawing correctly..mph.

regards,
Hamish

Hamish said:

I have a problem with the automatic adjustment of font size in
d.legend. Using frames, I created the following display:
http://moritz.homelinux.org/misc/good_legend.png
where everything displays fine. But when I try to reduce the width of

the frame containing the raster legend, I get the following result:
http://moritz.homelinux.org/misc/bad_legend.png

In an (old) thread
(http://thread.gmane.org/gmane.comp.gis.grass.devel/154) Hamish said

"the maxfontsize= functionality is somewhat unneeded now that font size
will auto-adjust if it is too large for the window", but this does not
seem to work in my case...

Any hints ?

Auto-scaling text is only implemented for categorical legends.
I'll look into getting it working for gradient legends too.

Legend text is generally controlled by the height of the legend box.

Yes, it scales if I change the vertical size:
http://moritz.homelinux.org/misc/small_legend.png

Another option is to use the use= option. :wink: This will make a category

legend & thus auto-scale the text. From the look of your map, this may
be suited to your data..

Even though it might not seem so, there are 589 categories in this map, so
the use option is not very practical. (Actually this map is complete
nonsense, I'm just using it for a proof of concept)

BTW, have you tried the new horizontal legends? Maybe that is more

appropriate for your map?

How do I create those, I didn't find it obvious to grasp that from the man
page ?

Also, your "good" legend seems to have some label cruft ")" in it; try

using the -v flag.

Yup, works, thanks !

Moritz

>> I have a problem with the automatic adjustment of font size in
>> d.legend. Using frames, I created the following display:
>> http://moritz.homelinux.org/misc/good_legend.png
>> where everything displays fine. But when I try to reduce the width
>> of the frame containing the raster legend, I get the following result:
>> http://moritz.homelinux.org/misc/bad_legend.png
>> In an (old) thread
>> (http://thread.gmane.org/gmane.comp.gis.grass.devel/154) Hamish said
>> "the maxfontsize= functionality is somewhat unneeded now that font
>> size will auto-adjust if it is too large for the window", but this
>> does not seem to work in my case...
>> Any hints ?
>
> Auto-scaling text is only implemented for categorical legends.
> I'll look into getting it working for gradient legends too.

Ok, I just added support for FP (gradient) legends, please test.

I know it will give odd looking output if you auto-scale when using the
flip flag, the solution means adding a pre-formatting loop to know in
advance what the longest text string will be. That's more work than I
want to do right now for a corner case. Maybe if some is desperate I'll
revisit it.

> Another option is to use the use= option. :wink: This will make a
> category legend & thus auto-scale the text. From the look of your
> map, this may be suited to your data..

Even though it might not seem so, there are 589 categories in this
map, so the use option is not very practical. (Actually this map is
complete nonsense, I'm just using it for a proof of concept)

Ok, you might try the "-n" flag to only draw categories with labels
then or play with the "thin=" & "range=" options.

> BTW, have you tried the new horizontal legends? Maybe that is more
> appropriate for your map?

How do I create those, I didn't find it obvious to grasp that from the
man page ?

quoth:
"When using the mouse or at= to size & place the legend, a user may
create a horizontal legend by making the box wider than it is tall."

regards,
Hamish