Ticket #124 (closed enhancement: worksforme)

Opened 7 years ago

Last modified 7 years ago

d.legend: apply arbitrary labels to a smooth floating-point colorbar

Reported by: epatton Owned by: hamish
Priority: minor Milestone: 6.4.0
Component: Default Version: svn-trunk
Keywords: colorbar, d.legend Cc: grass-dev@…
Platform: CPU:

Description

In d.legend, one is able to request arbitrary cat values for labelling with the use= parameter, but doing so creates blocks around each cat value requested in the output color bar. I would like to request the ability to arbitrarily label values on a *smoothed* color bar for a floating-point raster. d.legend makes nice color bars for floating point elevation/bathymetry rasters, I would just like it to label whatever set of values I give it, while maintaining the nice, smooth color bar over the entire range of raster values.

~ Eric.

Attachments

legend1.png Download (8.2 KB) - added by epatton 7 years ago.
Legend showing smooth, continous color bar for floating-point raster.
legend2.png Download (10.9 KB) - added by epatton 7 years ago.
Legend 2 allows user-defined labels, but chops legend into blocks

Change History

Changed 7 years ago by hamish

  • cc grass-dev@… added
  • owner changed from grass-dev@… to hamish
  • status changed from new to assigned

A few other buggy things to note,

use=0.0,0.2,0.4,0.6,0.8,1.0 only keeps the int part.

IIRC use= for FP with a categorty label used to display the label but doesn't anymore (may be bad memory, need to go back and test with GRASS 5)

Eric, may I ask for an example? Lock a tick-label at 0? Log scale? Should we allow numbers to overlap?

Hamish

Changed 7 years ago by epatton

Legend showing smooth, continous color bar for floating-point raster.

Changed 7 years ago by epatton

Legend 2 allows user-defined labels, but chops legend into blocks

Changed 7 years ago by epatton

Ok, for instance, see legend1.png; it shows a color bar divided into 6 intervals on a floating-point bathymetry dataset; I don't want to use odd depth values like -188 and -92; I would prefer to label -200, -150, -100, etc. When I use the use= paramter, the legend gets chopped into squares, ruining the nice, continous color bar (legend2.png; also, the labels become huge for some reason).

So basically, I would ideally like a color bar like legend1.png, but with arbitrary labels applied.

Changed 7 years ago by hamish

Using the range= and labelnum= options you should be able to get the look you are after.

d.legend range=0,-200

then you get labelnum=5 ticks at: 0,-50,-100,-150,-200

  • adjust your color rules so that they cover the full range
  • with the range= option do max,min instead of min,max to flip the legend vertically (or use the -f flag)

see also ps.map's colorbar legends. They work the other way and try to fall on round numbers automatically. Both ways have their merits, but I guess I hear less complaints about the ps.map way. (but less people use that, so who knows)

Hamish

Changed 7 years ago by epatton

  • status changed from assigned to closed
  • resolution set to worksforme

Ok, great! This is what I was looking for. Sorry for the noise; I misinterpreted what labelnum= was used for, and so never tried it in combination with range=. For most cases I should be able to play with labelnum to get the right divisor into the raster range.

Thanks; closing request,

~ Eric.

Note: See TracTickets for help on using tickets.