-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
[Bug]: get_ticklabels
/set_ticklabels
gives incorrect values in log plot
#29284
Comments
There is a note in the
If you want to keep the automatic tick placement but change the formatting of the labels, have a look at Tick Formatters. |
Yes, we do get the warning. Does the tick auto-scaling mean that this mis-labeling is expected in certain cases? |
Yes, this can happen. tick instances are internally reused. Their position is moved by the locator, their text is updated by the formatter. If you set fixed texts only, ticks can still move, and then, your fixed text is shown in an unexpected position. |
I wonder if we should make the documentation and/or warning more explicit, e.g "Use of set_ticklabels with unfixed tick positions may result in mislabelled ticks." |
Ok, so to clarify: by calling The root of our issue was that font |
@rcomer The documentation already says
and IIRC, the warning is issued from a quite generic place, which makes it difficult to give more specific directions. But if you see a possibility for improving the wording that’s always welcome. —- On a side note, I would have expected that at least |
Ah, it gets even weirder: in my example at the top of this thread, At this point I understand why the bug happened but it was definitely unexpected. Can the warning just be amended to:
|
@elimbaum for the Unicode minus have a look at |
Bug summary
In a certain scenario, adjusting the
ylim
of a log plot and updating theyticklabels
gives numerically incorrect ticks while still plotting the correct values. We were callingget_
/set_yticklabels
because thecmss10
font didn't have a certain glyph which needed to be replaced, but the bug can be reproduced with the more minimal code below.Code for reproduction
Actual outcome
The y-axis ticks are incorrectly labeled.
Expected outcome
Additional information
Changing
plt.ylim(None, plt.ylim()[1] * 8)
toplt.ylim(None, plt.ylim()[1] * 7)
(that is, just a bit less extra room) fixes the issue. Granted, most other sets of changes also fix it: this appears to be an extremely idiosyncratic bug, so I'm not clear what the real issue is. Changing the plot size, removing'constrained'
, changing the font, removing theylim
statement entirely... these all appear to fix it. It's just the specific combination of parameters that we happened to stumble into this.Operating system
Mac OS
Matplotlib Version
3.9.3
Matplotlib Backend
macosx
Python version
3.10.2
Jupyter version
N/A
Installation
pip
The text was updated successfully, but these errors were encountered: