-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: clabels with logarithmic axes #27081
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
Comments
Oh my! That is an embarrassingly simple solution to my problem! Thanks a lot! 😄 Does this still count as a bug so I keep the issue open, or is this expected behaviour? |
I think making the original example work would require calculating the labels (and modifying the contours) at draw time rather than when It might be better to wait for a more experienced developer to weigh in though. |
I think @rcomer is correct. In general it is safest to assume things are "drawn" when you call them. In addition to very substantial inefficiencies, it would require a whole lot of machinery to carry around the clabel info until draw time. |
Per #26971 (comment) I think the proper solution is to add support for knockout groups in Matplotlib's rendering model (as described in the linked comment). Otherwise implementation would be quite complex. |
One thing that would help in the case here, though, is to pass use_clabeltext=True -- at least the labels rotation is correct, even though the space removed around them is still wrong. |
Looking at it again, a possible fix would be to only do the linebreaking temporarily in draw(), i.e. add_label() would just register that a label needs to be added at a given position, but all calculations would be deferred until the very latest point, where the correct transforms are known. |
Bug summary
I am using clabels. However, when introducing logarithmic axes, the inline placement becomes inaccurate.
Code for reproduction
Actual outcome
Expected outcome
What is quite interesting: If I create several subplots with an identical content, using shared x and y axes, all but the first plot will show the correct behaviour.
This code:
with the X, Y, Z values from above, lead to this plot:
Note that this only provides the correct results for
sharex=True
andsharey=True
, if one (or both) are set to False, results are invalid.Additional information
No response
Operating system
Linux and MacOS
Matplotlib Version
3.7.3
Matplotlib Backend
QtAgg
Python version
3.8.10
Jupyter version
6.0.3
Installation
pip
The text was updated successfully, but these errors were encountered: