New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extraneous invalid ticks with colorbar extend keyword #4181
Comments
I see where the problem is coming from, I think: it's a matter of a slight tweak to try to handle the inexact nature of floating point arithmetic. The tweak bounds are too loose. I'm not sure yet whether the solution will be tightening the bounds, or changing the strategy. Thank you, @u55, for a nice, clear example. |
You are welcome, and thank you @efiring for the fast reply. Speaking of strategy, I find it odd that the tick Locator is allowed to return ticks that are outside of the requested range given by the import matplotlib.ticker as ticker
print(ticker.MaxNLocator().tick_values(0.02,0.2))
>>> [ 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22] Why is the last tick, 0.22, even allowed? I realize that it is convenient for matplotlib to allow users to manually enter ticks that may be outside of the current view limits, and therefore matplotlib must dismiss those ticks at draw time. But I assume that the |
IIRC, some of this probably came about in a fix for a big problem where On Mon, Mar 2, 2015 at 3:09 PM, u55 notifications@github.com wrote:
|
I think this is to facilitate auto-scaling based on expanding the range to tick values. Probably the Locator classes should all implement a "strict" option, maybe with a tolerance parameter, so I wouldn't have to put this in the colorbar itself. @WeatherGod, I think your hypothesis is an additional rationale. |
BUG : edit tick locations based on vmin and vmax; closes #4181
Hi matplotlib developers,
I discovered that the tick values and tick locations on a colorbar can be incorrect when the colorbar
extend
keyword is set to anything other than the default value of'neither'
. The ticks are sometimes displayed when they should be out of range, and even so, they are located in the wrong places, often overlapping with other correctly-placed ticks. Here is a minimal working example:Tested with matplotlib 1.4.3, python 2.7, on Linux and Windows.
In the example above, the colorbars on the left subplots, created with
extend='both'
, have extra ticks that are incorrect and are not present in the colorbars on the right created usingextend='neither'
. The existence of incorrect ticks depends strongly on the chosen clim range and the chosen tick Locator. On a linear colorscale, in the example above, the tick Locator adds an extra tick value of 0.22 even though the maximum clim value is set to 0.2, and the extra tick overlaps with the valid tick at 0.2. On a log colorscale, in the example above, the tick Locator add two extra ticks with values of 1e-2 and 1e-3, even though the minimum clim value is set to 2e-2.As a temporary workaround, I have been using this function to filter out the bad ticks and then set them manually:
But this only fixes the symptom, not the underlying problem, which I believe has something to do with the way the colorbar axes view limits are handled at draw time.
I appreciate anyone's help in finding a more permanent fix to this bug.
Thanks.
The text was updated successfully, but these errors were encountered: