Opened 9 years ago

Closed 8 years ago

#3015 closed enhancement (fixed)

Add legend title

Reported by: annakrat Owned by: grass-dev@…
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)

legend_shifted_units_mapdisplay.png (166.5 KB ) - added by veroandreo 9 years ago.
shifted units in legend - generated in main map display
legend_shifted_units_gguipsmap.png (153.3 KB ) - added by veroandreo 9 years ago.
shifted units in map legend - generated in g.gui.psmap

Download all attachments as: .zip

Change History (14)

by veroandreo, 9 years ago

shifted units in legend - generated in main map display

by veroandreo, 9 years ago

shifted units in map legend - generated in g.gui.psmap

comment:1 by veroandreo, 9 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)

comment:2 by lazaa, 9 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.

Last edited 9 years ago by lazaa (previous) (diff)

in reply to:  2 ; comment:3 by annakrat, 9 years ago

Replying to lazaa:

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.

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.

in reply to:  3 ; comment:4 by lazaa, 9 years ago

Replying to annakrat:

Replying to lazaa:

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.

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?

in reply to:  4 comment:5 by annakrat, 9 years ago

Replying to lazaa:

Replying to annakrat:

Replying to lazaa:

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.

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:6 by annakrat, 9 years ago

In 68671:

d.legend: improvements by Adam Laza: ticks, new options for labels, title, see #3014, #3015

comment:7 by annakrat, 8 years ago

Milestone: 7.3.07.2.0
Resolution: fixed
Status: newclosed

comment:8 by neteler, 8 years ago

Resolution: fixed
Status: closedreopened

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:9 by annakrat, 8 years ago

Works for me in trunk...

in reply to:  9 comment:10 by neteler, 8 years ago

Version: unspecifiedsvn-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 annakrat, 8 years ago

I backported r69160. Please test this and #3132 and both could be closed.

comment:12 by neteler, 8 years ago

Resolution: fixed
Status: reopenedclosed

Excellent, thanks for the fix.

Note: See TracTickets for help on using tickets.