[GRASS-dev] [GRASS GIS] #1049: optional histogram sidebar for legends

#1049: optional histogram sidebar for legends
------------------------------+---------------------------------------------
Reporter: hamish | Owner: grass-dev@lists.osgeo.org
     Type: enhancement | Status: new
Priority: minor | Milestone: 7.0.0
Component: Display | Version: svn-trunk
Keywords: d.legend, ps.map | Platform: All
      Cpu: All |
------------------------------+---------------------------------------------
Hi,

I notice that VisIt has a neat feature to its color legends that let you
incorporate a cumulative | frequency distribution graph along side the
main color-gradient. It would be neat if d.legend & ps.map had that sort
of capability.

examples:
  https://wci.llnl.gov/codes/visit/media/gallery/large_gallery_34.jpg
  https://wci.llnl.gov/codes/visit/media/gallery/gallery_05.jpg

Hamish

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

#1049: optional histogram sidebar for legends
------------------------------+---------------------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: enhancement | Status: new
Priority: minor | Milestone: 7.0.0
Component: Display | Version: svn-trunk
Keywords: d.legend, ps.map | Platform: All
      Cpu: All |
------------------------------+---------------------------------------------

Comment(by hamish):

it shouldn't be too hard:

look at how many pixels tall the FP legend is drawn on the display, then
get freq. data from 'r.stats nsteps=', so one value per screen line, scale
max width to equal the width of the legend box, then draw a series of
color= horizontal lines on the display connected to the left size of the
legend (other side from the text). -f is already used so I guess -d for
'distribution'.

Is there any demand for cumulative? or is histogram enough?

Hamish

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

#1049: optional histogram sidebar for legends
------------------------------+---------------------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: enhancement | Status: new
Priority: minor | Milestone: 7.0.0
Component: Display | Version: svn-trunk
Keywords: d.legend, ps.map | Platform: All
      Cpu: All |
------------------------------+---------------------------------------------

Comment(by hamish):

Hi,

legend histogram sidebars added to d.legend in trunk with r60093.

--
todo: support for CELL maps and constrained range=s.

For CELL maps we can perhaps interpolate between dist_stats->mincat and
dist_stats->maxcat ?

I'm not sure how to get r.stats to deal with constrained range= while
retaining pixel-height number of bins. Any ideas?

Hamish

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

#1049: optional histogram sidebar for legends
------------------------------+---------------------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: enhancement | Status: new
Priority: minor | Milestone: 7.0.0
Component: Display | Version: svn-trunk
Keywords: d.legend, ps.map | Platform: All
      Cpu: All |
------------------------------+---------------------------------------------

Comment(by hamish):

Hi,

I've added to this ticket a screenshot of the new functionality.

  https://trac.osgeo.org/grass/attachment/ticket/1049/dleg_histo.png

shown is a horizontal legend for elevation.10m from Spearfish drawn with a
histogram (-d flag), flipped left-right (-f flag, but setting at= as
max,min has the same effect [wxGUI currently seems to be sorting at=, so
that isn't working from the mouse]), and since I set the data units= with
r.support the legend now displays "meters" too without needing a separate
call to d.text.

the color rules there are a new addition as well, "roygbiv". In the
screenshot r.colors was run with the -e flag so the color scaling is set
to equal areas under the histogram curve instead of a linear color
transition from min to max.

have fun,
Hamish

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

#1049: optional histogram sidebar for legends
------------------------------+---------------------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: enhancement | Status: new
Priority: minor | Milestone: 7.0.0
Component: Display | Version: svn-trunk
Keywords: d.legend, ps.map | Platform: All
      Cpu: All |
------------------------------+---------------------------------------------

Comment(by hamish):

histogram support for categorical legends added in trunk with r60138.

screenshot:
   https://trac.osgeo.org/grass/attachment/ticket/1049/dleg_histo_soils.png

note there's a rendering bug in D_box_abs() + the PNG driver wrt subpixel
rounding or closing-strokes. (run xmag on the right end of the legend in
the screenshot)

Hamish

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