Opened 8 years ago

Closed 2 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 4 years ago.
demo of new functionality
dleg_histo_soils.png (5.1 KB) - added by hamish 4 years ago.
horizontal cats legend with histogram

Download all attachments as: .zip

Change History (7)

comment:1 Changed 5 years ago 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?


comment:2 Changed 4 years ago by hamish


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?


Changed 4 years ago by hamish

Attachment: dleg_histo.png added

demo of new functionality

comment:3 Changed 4 years ago by hamish


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

Changed 4 years ago by hamish

Attachment: dleg_histo_soils.png added

horizontal cats legend with histogram

comment:4 Changed 4 years ago by hamish

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 Changed 2 years ago by annakrat

Resolution: fixed
Status: newclosed

This seems to be completed.

Note: See TracTickets for help on using tickets.