Yes, sort of. This is one of the warts in matplotlib's design. Several
things are deferred until draw time. Axes ticks are one of them. There are
similar problems with facecolors of some scalar mappables that are
initialized to blue to start but won't get their final color until draw
time.
It isn't a bug, per se, but it is a wart. We really should make it so that
calls like get_xticklabels() forces the artist to not defer any longer and
compute their relevant values.
matplotlib 1.5.1 on Linux, installed from binary package, both on Python
3.5.2 and 2.7.12.
Here is the code:
import pylab
f, axes = pylab.subplots(2, sharex=True, sharey=True)for ax in axes:
ax.plot(range(100))for ax in axes:
print([x.get_text() for x in ax.get_xticklabels()])print('----')
pylab.savefig('/tmp/tempfig.png')for ax in axes:
print([x.get_text() for x in ax.get_xticklabels()])
This is indeed a dupe, sorry for not searching thoroughly enough. Feel free to close it as such or do whatever you think is better.
At least I get the idea now, thank you.
It's fine! ('specially since I created the other issue...). I'm just wondering out loud about where something can be slotted in to alleviate some of this confusion.
That's because I don't know the API so well.
I was trying to re-set the tick labels just to change their font size.
I have already figured out that I can use setp() for that.
Oh, @tacaswellhttps://github.com/tacaswell what about a warning on the
get_methods if you try and call 'em before the figure is drawn? (or is that
way too much overhead...)
Activity
WeatherGod commented on Jul 19, 2016
Yes, sort of. This is one of the warts in matplotlib's design. Several
things are deferred until draw time. Axes ticks are one of them. There are
similar problems with facecolors of some scalar mappables that are
initialized to blue to start but won't get their final color until draw
time.
It isn't a bug, per se, but it is a wart. We really should make it so that
calls like get_xticklabels() forces the artist to not defer any longer and
compute their relevant values.
On Tue, Jul 19, 2016 at 1:47 PM, Lev Levitsky notifications@github.com
wrote:
story645 commented on Jul 19, 2016
This is kinda a dupe of #6638 so wondering if at least for now it should at the least be a doc patch? (Where though...)
levitsky commented on Jul 19, 2016
This is indeed a dupe, sorry for not searching thoroughly enough. Feel free to close it as such or do whatever you think is better.
At least I get the idea now, thank you.
story645 commented on Jul 19, 2016
It's fine! ('specially since I created the other issue...). I'm just wondering out loud about where something can be slotted in to alleviate some of this confusion.
tacaswell commented on Jul 19, 2016
A better question is why are you trying to do this?
levitsky commented on Jul 19, 2016
That's because I don't know the API so well.
I was trying to re-set the tick labels just to change their font size.
I have already figured out that I can use setp() for that.
story645 commented on Jul 19, 2016
@tacaswell what about a warning on the get_methods if you try and call 'em before the figure is drawn? (or is that way too much overhead...)
WeatherGod commented on Jul 19, 2016
The problem is that it is only some methods that are problematic, and I
don't think anybody has a clear idea which ones they are.
On Tue, Jul 19, 2016 at 3:05 PM, hannah notifications@github.com wrote:
QuLogic commented on Dec 20, 2022
This was fixed by #23170.