Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#3081 closed enhancement (fixed)

Add text after labels in d.legend

Reported by: wenzeslaus Owned by: grass-dev@…
Priority: minor Milestone: 7.4.0
Component: Display Version: unspecified
Keywords: d.legend, cartography Cc:
CPU: Unspecified Platform: Unspecified

Description

Now G7:d.legend can show only the numbers for a given values and it looks like this:

|  | 150
|  | 100
|  | 50
|  | 0

I would like to attach a unit to each number, i.e. show the value and its units, something like this:

|  | 150 m
|  | 100 m
|  | 50 m
|  | 0 m

The unit can/could be taken from raster map units (i.e. what G7:r.info gives) but I need to specify units manually because the unit is not always written in the metadata or it it not in the right form. Examples include degrees (deg, °) and percents (percentages, %).

The question is how to deal with the space between the number and the text (unit). Different languages (and fields) has different standards, so there should be probably a flag which would do it or the spaces would be just provided as part of the label (which might be less clear especially in the command line).

This applies just to continuous data but I don't see a reason to somehow disable this behavior for categorical legends.

Attachments (2)

slope.png (16.6 KB ) - added by lazaa 8 years ago.
d.legend raster=slope units=% label_step=5 -wb
d.leg.units.diff (19.3 KB ) - added by lazaa 8 years ago.
added option units, without -w flag. Side histogram fixed

Download all attachments as: .zip

Change History (8)

comment:1 by lazaa, 8 years ago

We could add option units which would display unit after every label or maybe just under the legend for all labels? It seems to me more user friendly by default display units with whitespace after label and for cases of degrees or percentages add a new flag.

in reply to:  1 ; comment:2 by wenzeslaus, 8 years ago

Type: defectenhancement

Replying to lazaa:

We could add option units which would display unit after every label

This is what I mean. units sounds good.

or maybe just under the legend for all labels?

The feature of adding it there for all was already there (I'm not sure about the current situation). When the raster had units set (​G7:r.info gives those), they would be show where the title currently is displayed. This still makes sense but it is more discussion about the title I think.

It seems to me more user friendly by default display units with whitespace after label and for cases of degrees or percentages add a new flag.

Agreed. Space by default might lead to better results in most cases. Flag for disabling solves the rest (when people need no space).

in reply to:  2 comment:3 by lazaa, 8 years ago

Replying to wenzeslaus:

Replying to lazaa:

We could add option units which would display unit after every label

This is what I mean. units sounds good.

or maybe just under the legend for all labels?

The feature of adding it there for all was already there (I'm not sure about the current situation). When the raster had units set (​G7:r.info gives those), they would be show where the title currently is displayed. This still makes sense but it is more discussion about the title I think.

The feature is still there. Units are displayed under the legend if r.info gives those and no title is set (this should be probably changed so both units and title could be displayed at the same time if defined).

It seems to me more user friendly by default display units with whitespace after label and for cases of degrees or percentages add a new flag.

Agreed. Space by default might lead to better results in most cases. Flag for disabling solves the rest (when people need no space).

by lazaa, 8 years ago

Attachment: slope.png added

d.legend raster=slope units=% label_step=5 -wb

comment:4 by lazaa, 8 years ago

Added option units and flag -w to suppress whitespace between label and unit.

by lazaa, 8 years ago

Attachment: d.leg.units.diff added

added option units, without -w flag. Side histogram fixed

comment:5 by annakrat, 8 years ago

Resolution: fixed
Status: newclosed

Committed in r69000.

comment:6 by martinl, 8 years ago

Milestone: 7.3.07.4.0

Milestone renamed

Note: See TracTickets for help on using tickets.