Opened 8 years ago
Closed 8 years ago
#3015 closed enhancement (fixed)
Add legend title
| Reported by: | annakrat | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.2.0 |
| Component: | Display | Version: | svn-releasebranch72 |
| Keywords: | d.legend, gsoc2016, cartography | Cc: | |
| CPU: | Unspecified | Platform: | All |
Description
Currently legend shows title only in case raster has set units using r.support. The text is shifted awkwardly to right. Legend should have an option to set the title directly.
Attachments (2)
Change History (14)
by , 8 years ago
| Attachment: | legend_shifted_units_mapdisplay.png added |
|---|
by , 8 years ago
| Attachment: | legend_shifted_units_gguipsmap.png added |
|---|
shifted units in map legend - generated in g.gui.psmap
comment:1 by , 8 years ago
Ops! I sent attachments before comment (again!). Maybe (un)related, but after using r.support, units are shifted even more awkwardly when calling colortable from g.gui.psmap or ps.map.
The attachments illustrate the behaviour, both adding legend from main map display (first fig) and calling colortable from g.gui.psmap (second fig)
follow-up: 3 comment:2 by , 8 years ago
I want to add an option title that displays custom label at the top of the legend. Should I keep displaying the text with units when raster has set units using r.support? I don't like it, it's not actually a title. If necessary I can add another option for displaying units but I would prefer at different position than at the top of the legend.
follow-up: 4 comment:3 by , 8 years ago
Replying to lazaa:
I want to add an option
titlethat displays custom label at the top of the legend. Should I keep displaying the text with units when raster has set units using r.support? I don't like it, it's not actually a title. If necessary I can add another option for displaying units but I would prefer at different position than at the top of the legend.
I would keep the current behavior there (perhaps try to fix the position) and if user specifies title, the title would be shown, not the units. Any other opinions are welcome of course.
follow-up: 5 comment:4 by , 8 years ago
Replying to annakrat:
Replying to lazaa:
I want to add an option
titlethat displays custom label at the top of the legend. Should I keep displaying the text with units when raster has set units using r.support? I don't like it, it's not actually a title. If necessary I can add another option for displaying units but I would prefer at different position than at the top of the legend.I would keep the current behavior there (perhaps try to fix the position) and if user specifies title, the title would be shown, not the units. Any other opinions are welcome of course.
Ok, I will keep it. In both cases of title or units the text should be aligned to the left border of legend, right?
comment:5 by , 8 years ago
Replying to lazaa:
Replying to annakrat:
Replying to lazaa:
I want to add an option
titlethat displays custom label at the top of the legend. Should I keep displaying the text with units when raster has set units using r.support? I don't like it, it's not actually a title. If necessary I can add another option for displaying units but I would prefer at different position than at the top of the legend.I would keep the current behavior there (perhaps try to fix the position) and if user specifies title, the title would be shown, not the units. Any other opinions are welcome of course.
Ok, I will keep it. In both cases of title or units the text should be aligned to the left border of legend, right?
I would think so.
comment:7 by , 8 years ago
| Milestone: | 7.3.0 → 7.2.0 |
|---|---|
| Resolution: | → fixed |
| Status: | new → closed |
comment:8 by , 8 years ago
| Resolution: | fixed |
|---|---|
| Status: | closed → reopened |
Specifying a title leads to a parse error:
GRASS 7.2.svn (latlong_wgs84):~/Downloads > d.legend raster="magnitude" at=90.3,94.7,1.8,26.5 title="Wind magnitude [knots]"
Drawing horizontal legend as box width exceeds height
GRASS 7.2.svn (latlong_wgs84):~/Downloads > Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/_misc.py", line 1358, in Notify
self.notify()
File "/home/mneteler/software/grass72/dist.x86_64-pc-linux-gnu/gui/wxpython/mapdisp/main.py", line 578, in watcher
self.mapFrm.GetMap().GetLayersFromCmdFile()
File "/home/mneteler/software/grass72/dist.x86_64-pc-linux-gnu/gui/wxpython/mapdisp/main.py", line 201, in GetLayersFromCmdFile
self._giface.GetMapDisplay().AddLegendRast(cmd=cmd)
File "/home/mneteler/software/grass72/dist.x86_64-pc-linux-gnu/gui/wxpython/mapdisp/frame.py", line 1245, in AddLegendRast
cmd, completed=(self.GetOptData, None, None))
File "/home/mneteler/software/grass72/dist.x86_64-pc-linux-gnu/gui/wxpython/gui_core/forms.py", line 2833, in ParseCommand
_("Unable to parse command '%s'") % ' '.join(cmd))
core.gcmd.GException: Unable to parse command 'd.legend raster=magnitude title=Wind raster=magnitude [knots] color=black labelnum=5 lines=0 bgcolor=white at=90.3,94.7,1.8,26.5 border_color=black thin=1'
Likewise with NC SPM:
GRASS 7.2.svn (nc_spm_08_grass7):~ > d.legend raster=elevation title="Elevation [m]"
GRASS 7.2.svn (nc_spm_08_grass7):~ > ERROR: Failed to run command 'd.legend raster=[m] at=5,50,47,50
title=Elevation'. Details:
GRASS_INFO_ERROR(16739,1): Raster map <[m]> not found
GRASS_INFO_END(16739,1)
"Just" a quoting issue it seems.
comment:10 by , 8 years ago
| Version: | unspecified → svn-releasebranch72 |
|---|
Replying to annakrat:
Works for me in trunk...
For me, too. But it 7.2 it doesn't... Maybe a d.mon issue?
comment:11 by , 8 years ago
comment:12 by , 8 years ago
| Resolution: | → fixed |
|---|---|
| Status: | reopened → closed |
Excellent, thanks for the fix.

shifted units in legend - generated in main map display