How to Control Number of Ticks in Color Legend?

Question: How can I control the number of ticks in the color legend?

I would like to set my color legend limits to a custom range between 0.0 and 0.1 (inclusive) with 3 internal ticks to indicate quartile ranges; however, I can find no way to control this value in the Properties Pane or the Edit Color Legend Properties dialog (with and without “advanced properties enabled”.

I’m also running into the issue that with a custom range and the font size I require, the results are undesirable (see attached). Note that rescaling to the data range alleviates the font issue; however, I’m still unable to find a way to specify the number of ticks.

My apologies for missing what is probably an obvious setting.

Joel,

The short answer is that you cannot specify just the number of ticks/labels to show, but you can specify the exact values at which you want ticks and labels to be displayed (and hence the number of ticks to show). In the Edit Color Legend Properties dialog, click to show advanced settings. You will see the Use Custom Labels checkbox. Check this, and you will see a table where you can enter as many labels as you wish. The caveat is that these labels will be drawn no matter what, even if they overlap each other.

The longer answer is that ParaView used to (kind of) let you specify the number of ticks, but it was really the maximum number of ticks to give ParaView some leeway for placement, avoiding overlapping ticks, etc. And it didn’t work that great at getting close to the number of requested ticks. The other common complaint was that the labels at those ticks had odd values, such as [0.0, 0.4357, 0.8714]. That’s a made up example, but representative of the old labels you might see show up unless you set the range to something with “nice” numbers on either end. In the new implementation starting with ParaView 5.4, we give ParaView either a) complete freedom to pick the labels, based on ideas of what make up “nice” numbers, how big the labels are and how big the color legend is, the DPI, etc. or b) give you complete control over exactly which ticks and labels you want to see. The middle ground where you suggest a maximum number of ticks, which was in versions prior to 5.4, has been removed.

As for the overlapping labels, an issue has already been posted, but it has not yet been prioritized.

Thanks,
Cory

This is great, but it would be better if we had some programmatic way of doing this. I mean manually adding 20 labels with regular spacing is no fun; meanwhile a simple python script could manage that.

You can set them via Python:

lut = GetColorTransferFunction("RTData")
sb = GetScalarBar(lut)
sb.UseCustomLabels = 1
# labels from 100 to 200 in increments of 10
sb.CustomLabels = xrange(100, 210, 10)
1 Like

Actually, it got much worse. This is paraview 5.9.1: