[GRASS-dev] [GRASS GIS] #3014: Add ticks to continuous raster legend

#3014: Add ticks to continuous raster legend
---------------------------------------------+-------------------------
Reporter: annakrat | Owner: grass-dev@…
     Type: enhancement | Status: new
Priority: normal | Milestone: 7.3.0
Component: Display | Version: svn-trunk
Keywords: d.legend, gsoc2016, cartography | CPU: Unspecified
Platform: All |
---------------------------------------------+-------------------------
Continuous legend should have option to add ticks, so that it is easier to
read. It would be good to have the option to add the tick numbers.

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

#3014: Add ticks to continuous raster legend
--------------------------+---------------------------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.3.0
Component: Display | Version: svn-trunk
Resolution: | Keywords: d.legend, gsoc2016, cartography
       CPU: Unspecified | Platform: All
--------------------------+---------------------------------------------

Comment (by lazaa):

Currently legend has ticks in regular intervals depend on {{{labelnum}}}.
The aim is to add option e.g. {{{steps=100}}} for display label every
hundred or {{{labels_at=[list of values]}}} to add one or more labels at
specific values? (value would have to be min < label_at < max)

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

#3014: Add ticks to continuous raster legend
--------------------------+---------------------------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.3.0
Component: Display | Version: svn-trunk
Resolution: | Keywords: d.legend, gsoc2016, cartography
       CPU: Unspecified | Platform: All
--------------------------+---------------------------------------------

Comment (by annakrat):

Replying to [comment:1 lazaa]:
> Currently legend has ticks in regular intervals depend on
{{{labelnum}}}. The aim is to add option e.g. {{{steps=100}}} for display
label every hundred or {{{labels_at=[list of values]}}} to add one or more
labels at specific values? (value would have to be min < label_at < max)

Start with drawing the tick marks based on `labelnum`. You should probably
center the label at the tick.

If we want to further complicate it, there is couple of options. For
example, we could have a parameter `tick_value` (or something similar)
where user would specify values where to plot the ticks and labels.

Another option is to add `tick_step` which would create ticks based on the
step. But the `tick_start` may be needed to know where to draw the first
one.

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

#3014: Add ticks to continuous raster legend
--------------------------+---------------------------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.3.0
Component: Display | Version: svn-trunk
Resolution: | Keywords: d.legend, gsoc2016, cartography
       CPU: Unspecified | Platform: All
--------------------------+---------------------------------------------

Comment (by lazaa):

I uploaded new patch and I added several new options. Option {{{title}}}
to define custom title to display on the top of the legend.
{{{
d.legend raster=srtm title="Map legend"
}}}
An option {{{tick_value}}} to specify values where the ticks and labels
will be displayed. Option {{{labelnum}}} is used to show only min and max.
{{{
d.legend raster=srtm labelnum=2 tick_value=1000,1848,2700,3500
}}}
Then option {{{step}}} to draw ticks and display labels at rounded values-
values divisible by {{{step}}} value with rest 0. (Flag {{{-c}}} is used
to hide labels generated from {{{labelnum}}} and to display only labels
with defined interval.)
{{{
d.legend raster=srtm -c step=500
}}}

I've tested it for vertical/horizontal and normal/flipped legend it works
fine. There's a problem with horizontal legend if user define more ticks
then longer labels can overlap.

More testing welcome.

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

#3014: Add ticks to continuous raster legend
--------------------------+---------------------------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.3.0
Component: Display | Version: svn-trunk
Resolution: | Keywords: d.legend, gsoc2016, cartography
       CPU: Unspecified | Platform: All
--------------------------+---------------------------------------------
Changes (by lazaa):

* Attachment "d.legend.diff" added.

added several options for d.legend

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

#3014: Add ticks to continuous raster legend
--------------------------+---------------------------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.3.0
Component: Display | Version: svn-trunk
Resolution: | Keywords: d.legend, gsoc2016, cartography
       CPU: Unspecified | Platform: All
--------------------------+---------------------------------------------

Comment (by annakrat):

Thanks, I tested it and it works very well. I have couple of suggestions:

* if you compare the default before and after this change, the white
border is now transparent, so that should be changed back. Also if you
test categorical data, the black/white border is switched (inner is black,
should be white). The current default legend size is wider than the
previous one, that should be fixed as well.

* drawing ticks should be optional, implement for example '-t' flag.
Question is if it should draw the ticks by default or not. Let's switch
them off by default for now.

* the vertical centering of the labels and ticks is not quite perfect, I
wonder if it could be improved

* I thought more about the names of the new parameters and decided
`label_values` and `label_step` would fit more to `labelnum`

* the `-c` flag should always hide all the numbers, it is actually useful
mostly with categorical data

* I think when option `label_value` or `label_step` is used, `labelnum`
should be ignored. So the min max values won't be displayed. I hope we
could get some feedback from other users what kind of behavior would be
more natural.

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

#3014: Add ticks to continuous raster legend
--------------------------+---------------------------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.3.0
Component: Display | Version: svn-trunk
Resolution: | Keywords: d.legend, gsoc2016, cartography
       CPU: Unspecified | Platform: All
--------------------------+---------------------------------------------
Changes (by lazaa):

* Attachment "d.legend2.diff" added.

updated patch

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

#3014: Add ticks to continuous raster legend
--------------------------+---------------------------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.3.0
Component: Display | Version: svn-trunk
Resolution: | Keywords: d.legend, gsoc2016, cartography
       CPU: Unspecified | Platform: All
--------------------------+---------------------------------------------
Changes (by lazaa):

* Attachment "legends.png" added.

legend examples

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

#3014: Add ticks to continuous raster legend
--------------------------+---------------------------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.3.0
Component: Display | Version: svn-trunk
Resolution: | Keywords: d.legend, gsoc2016, cartography
       CPU: Unspecified | Platform: All
--------------------------+---------------------------------------------

Comment (by lazaa):

Replying to [comment:4 annakrat]:
> Thanks, I tested it and it works very well. I have couple of
suggestions:
>
> * if you compare the default before and after this change, the white
border is now transparent, so that should be changed back. Also if you
test categorical data, the black/white border is switched (inner is black,
should be white). The current default legend size is wider than the
previous one, that should be fixed as well.
It's fixed, it should be the same like before.

> * drawing ticks should be optional, implement for example '-t' flag.
Question is if it should draw the ticks by default or not. Let's switch
them off by default for now.
{{{-t}}} option added. By default ticks are switched off.

> * the vertical centering of the labels and ticks is not quite perfect, I
wonder if it could be improved

It's the same problem with fonts like in d.grid. Centering works fine for
default GRASS_FONT. The problem is there's a constant which define the
width/height ratio of a letter.

> * I thought more about the names of the new parameters and decided
`label_values` and `label_step` would fit more to `labelnum`

I changed both option names.
> * the `-c` flag should always hide all the numbers, it is actually
useful mostly with categorical data

{{{-c}}} flag now hide all labels. {{{G_option_exclusive}}} is used so
user can't use {{{c}}} flag with {{{label_value}}} or {{{label_step}}}
option.

> * I think when option `label_value` or `label_step` is used, `labelnum`
should be ignored. So the min max values won't be displayed. I hope we
could get some feedback from other users what kind of behavior would be
more natural.
I add {{{G_option_exclusive}}} but please test it if everything is OK.

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

#3014: Add ticks to continuous raster legend
--------------------------+---------------------------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.3.0
Component: Display | Version: svn-trunk
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/3014#comment:6>
GRASS GIS <https://grass.osgeo.org>

#3014: Add ticks to continuous raster legend
--------------------------+---------------------------------------------
  Reporter: annakrat | Owner: grass-dev@…
      Type: enhancement | Status: closed
  Priority: normal | Milestone: 7.2.0
Component: Display | Version: svn-trunk
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/3014#comment:7&gt;
GRASS GIS <https://grass.osgeo.org>