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.
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.
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)
Actually, it got much worse. This is paraview 5.9.1:
I’ve continued to notice this issue, particularly when using horizontal colorbars:
It’s led to me pretty much only using horizontal colorbars with an “empty” custom ticks field that at least produces a legible colorbar with only annotations at the extents:
It appears that this is the GitLab issue: https://gitlab.kitware.com/paraview/paraview/-/issues/17786
I’m curious if there’s been any progress on the issue.
Just thinking, but it almost feels like each label needs a “hit-box” and then the colorbar functionality should ensure that the hit-boxes don’t overlap - if they do then it should reduce the amount of ticks until it finds a suitable distribution.
In the second image the tick labels are in scientific notation. Did you have Automatic Label Format on when you took the screenshot? Because in the later image you used float format, which saves some space.
You could also reduce the font size for the labels in Edit Color Legend Properties - Text/Annotation Font Properties.
Your observation is correct regarding the format, I did this on purpose to demonstrate these issues crop up a lot.
Also, while I could decrease the font size I’m of the belief that labels on a colorbar should be large enough to be legible.