[GRASS-dev] [GRASS GIS] #3015: Add legend title

#3015: Add legend title
---------------------------------------------+-------------------------
Reporter: annakrat | Owner: grass-dev@…
     Type: enhancement | Status: new
Priority: normal | Milestone: 7.3.0
Component: Display | Version: unspecified
Keywords: d.legend, gsoc2016, cartography | CPU: Unspecified
Platform: All |
---------------------------------------------+-------------------------
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.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3015&gt;
GRASS GIS <https://grass.osgeo.org>

#3015: Add legend title
--------------------------+---------------------------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.3.0
Component: Display | Version: unspecified
Resolution: | Keywords: d.legend, gsoc2016, cartography
       CPU: Unspecified | Platform: All
--------------------------+---------------------------------------------
Changes (by veroandreo):

* Attachment "legend_shifted_units_mapdisplay.png" added.

shifted units in legend - generated in main map display

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3015&gt;
GRASS GIS <https://grass.osgeo.org>

#3015: Add legend title
--------------------------+---------------------------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.3.0
Component: Display | Version: unspecified
Resolution: | Keywords: d.legend, gsoc2016, cartography
       CPU: Unspecified | Platform: All
--------------------------+---------------------------------------------
Changes (by veroandreo):

* Attachment "legend_shifted_units_gguipsmap.png" added.

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

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3015&gt;
GRASS GIS <https://grass.osgeo.org>

#3015: Add legend title
--------------------------+---------------------------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.3.0
Component: Display | Version: unspecified
Resolution: | Keywords: d.legend, gsoc2016, cartography
       CPU: Unspecified | Platform: All
--------------------------+---------------------------------------------

Comment (by veroandreo):

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)

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3015#comment:1&gt;
GRASS GIS <https://grass.osgeo.org>

#3015: Add legend title
--------------------------+---------------------------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.3.0
Component: Display | Version: unspecified
Resolution: | Keywords: d.legend, gsoc2016, cartography
       CPU: Unspecified | Platform: All
--------------------------+---------------------------------------------

Comment (by lazaa):

I want to add option {{{title}}} that display 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 then at the top of the legend.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3015#comment:2&gt;
GRASS GIS <https://grass.osgeo.org>

#3015: Add legend title
--------------------------+---------------------------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.3.0
Component: Display | Version: unspecified
Resolution: | Keywords: d.legend, gsoc2016, cartography
       CPU: Unspecified | Platform: All
--------------------------+---------------------------------------------

Comment (by annakrat):

Replying to [comment:2 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.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3015#comment:3&gt;
GRASS GIS <https://grass.osgeo.org>

#3015: Add legend title
--------------------------+---------------------------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.3.0
Component: Display | Version: unspecified
Resolution: | Keywords: d.legend, gsoc2016, cartography
       CPU: Unspecified | Platform: All
--------------------------+---------------------------------------------

Comment (by lazaa):

Replying to [comment:3 annakrat]:
> Replying to [comment:2 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?

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3015#comment:4&gt;
GRASS GIS <https://grass.osgeo.org>

#3015: Add legend title
--------------------------+---------------------------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.3.0
Component: Display | Version: unspecified
Resolution: | Keywords: d.legend, gsoc2016, cartography
       CPU: Unspecified | Platform: All
--------------------------+---------------------------------------------

Comment (by annakrat):

Replying to [comment:4 lazaa]:
> Replying to [comment:3 annakrat]:
> > Replying to [comment:2 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.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3015#comment:5&gt;
GRASS GIS <https://grass.osgeo.org>

#3015: Add legend title
--------------------------+---------------------------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.3.0
Component: Display | Version: unspecified
Resolution: | Keywords: d.legend, gsoc2016, cartography
       CPU: Unspecified | Platform: All
--------------------------+---------------------------------------------

Comment (by annakrat):

In [changeset:"68671" 68671]:
{{{
#!CommitTicketReference repository="" revision="68671"
d.legend: improvements by Adam Laza: ticks, new options for labels, title,
see #3014, #3015
}}}

--
Ticket URL: </ticket/3015#comment:6>
GRASS GIS <https://grass.osgeo.org>

#3015: Add legend title
--------------------------+---------------------------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: enhancement | Status: closed
  Priority: normal | Milestone: 7.2.0
Component: Display | Version: unspecified
Resolution: fixed | Keywords: d.legend, gsoc2016, cartography
       CPU: Unspecified | Platform: All
--------------------------+---------------------------------------------
Changes (by annakrat):

* status: new => closed
* resolution: => fixed
* milestone: 7.3.0 => 7.2.0

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3015#comment:7&gt;
GRASS GIS <https://grass.osgeo.org>

#3015: Add legend title
--------------------------+---------------------------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: enhancement | Status: reopened
  Priority: normal | Milestone: 7.2.0
Component: Display | Version: unspecified
Resolution: | Keywords: d.legend, gsoc2016, cartography
       CPU: Unspecified | Platform: All
--------------------------+---------------------------------------------
Changes (by neteler):

* status: closed => reopened
* resolution: fixed =>

Comment:

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.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3015#comment:8&gt;
GRASS GIS <https://grass.osgeo.org>

#3015: Add legend title
--------------------------+---------------------------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: enhancement | Status: reopened
  Priority: normal | Milestone: 7.2.0
Component: Display | Version: unspecified
Resolution: | Keywords: d.legend, gsoc2016, cartography
       CPU: Unspecified | Platform: All
--------------------------+---------------------------------------------

Comment (by annakrat):

Works for me in trunk...

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3015#comment:9&gt;
GRASS GIS <https://grass.osgeo.org>

#3015: Add legend title
--------------------------+---------------------------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: enhancement | Status: reopened
  Priority: normal | Milestone: 7.2.0
Component: Display | Version: svn-releasebranch72
Resolution: | Keywords: d.legend, gsoc2016, cartography
       CPU: Unspecified | Platform: All
--------------------------+---------------------------------------------
Changes (by neteler):

* version: unspecified => svn-releasebranch72

Comment:

Replying to [comment:9 annakrat]:
> Works for me in trunk...

For me, too. But it 7.2 it doesn't... Maybe a d.mon issue?

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3015#comment:10&gt;
GRASS GIS <https://grass.osgeo.org>

#3015: Add legend title
--------------------------+---------------------------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: enhancement | Status: reopened
  Priority: normal | Milestone: 7.2.0
Component: Display | Version: svn-releasebranch72
Resolution: | Keywords: d.legend, gsoc2016, cartography
       CPU: Unspecified | Platform: All
--------------------------+---------------------------------------------

Comment (by annakrat):

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

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3015#comment:11&gt;
GRASS GIS <https://grass.osgeo.org>

#3015: Add legend title
--------------------------+---------------------------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: enhancement | Status: closed
  Priority: normal | Milestone: 7.2.0
Component: Display | Version: svn-releasebranch72
Resolution: fixed | Keywords: d.legend, gsoc2016, cartography
       CPU: Unspecified | Platform: All
--------------------------+---------------------------------------------
Changes (by neteler):

* status: reopened => closed
* resolution: => fixed

Comment:

Excellent, thanks for the fix.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3015#comment:12&gt;
GRASS GIS <https://grass.osgeo.org>