Opened 14 years ago

Closed 8 years ago

#1049 closed enhancement (fixed)

optional histogram sidebar for legends

Reported by: hamish Owned by: grass-dev@…
Priority: minor Milestone: 7.0.0
Component: Display Version: svn-trunk
Keywords: d.legend, Cc:
CPU: All Platform: All



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 & had that sort of capability.



Attachments (2)

dleg_histo.png (4.9 KB ) - added by hamish 10 years ago.
demo of new functionality
dleg_histo_soils.png (5.1 KB ) - added by hamish 10 years ago.
horizontal cats legend with histogram

Download all attachments as: .zip

Change History (7)

comment:1 by hamish, 10 years ago

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?


comment:2 by hamish, 10 years ago


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?


by hamish, 10 years ago

Attachment: dleg_histo.png added

demo of new functionality

comment:3 by hamish, 10 years ago


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

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 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

by hamish, 10 years ago

Attachment: dleg_histo_soils.png added

horizontal cats legend with histogram

comment:4 by hamish, 10 years ago

histogram support for categorical legends added in trunk with r60138.


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)


comment:5 by annakrat, 8 years ago

Resolution: fixed
Status: newclosed

This seems to be completed.

Note: See TracTickets for help on using tickets.