Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Adding subplotpars to the plot stack#11796
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This is probably fine, but have you tried constrained layout? It also seems to me that this info is best kept on the GridSpec. I am away from computer a few days so can’t dig into it but each subplotspec should have a parent GridSpec that I thought held all this. |
Yes, the subplot parameters are also included in the gridspec for a subplot axes but the I have tested this implementation for different kinds of |
614a9b8
to3167833
CompareAdded an "interactive" test that fails on master. Any comments about the test structure? I am going to write more similar tests. Are there any reason to test more than one backend? |
3167833
tod647027
Compareax._set_view(view) | ||
# Restore both the original and modified positions | ||
ax._set_position(pos_orig, 'original') | ||
ax._set_position(pos_active, 'active') | ||
self.canvas.figure.subplotpars.update(**subplotpars) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I'm a little confused why you don't just do all this with thesubplotpars
object directly, rather than making a dictionary and then passing one back in. Does that not work for some reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I am not sure if I thought about it but I have tested it now and it didn't work well in same cases for same reason.
I also think that it feels better to read and copy the parameters and update the same object than copy the whole object and change object in_update_view
. I am not sure now but it is possibly that gridspec has a view to the SubplotParams object in figure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This does seem very odd...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is very likely because subplotpars are mutable, so even if you push them onto the stack they'll get mutated after the fact unless you make a copy first.
931d430
to6137e15
CompareI added some tests, maybe to many, maybe to slow. The tests work on my computer and travis with python 3.6. I don't understand what I can to make them pass on python 3.5 though. I get the following error
The problem is due to multiprocessing (or multi threading) together with parametrized tests but I don't understand how the information I have found about the error is related to my own code. |
6137e15
toa9b012a
CompareYou don't need all of those |
That is weird that it is collecting in a different order. It is likely due to the random iteration order of dictionaries in py3.5, presumably someplace inside of pytest. Would this be fixed by (modestly) bumping the pytest version? IIRC 3.5 is currently pinned to the minimum versions of many of our dependencies. I wonder if moving to a paramaterized class (or one paramaterized function) as@QuLogic suggested would solve this problem? |
Just pointing out that not all figures have subplot axes. Some figures willhave axes placed manually. I haven't read enough of this PR to know if thatis an issue or not. …On Tue, Aug 7, 2018 at 8:03 PM, Thomas A Caswell ***@***.***> wrote: That is weird that it is collecting in a different order. It is likely due to the random iteration order of dictionaries in py3.5, presumably someplace inside of pytest. Would this be fixed by (modestly) bumping the pytest version? IIRC 3.5 is currently pinned to the minimum versions of many of our dependencies. I wonder if moving to a paramaterized class (or one paramaterized function) as@QuLogic <https://github.com/QuLogic> suggested would solve this problem? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#11796 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AARy-L4_oodm0hheQLVYV2uSCc0e7CZRks5uOirugaJpZM4Vlfyf> . |
Well, it's definitely a thing caused by pytest-xdist, possibly related topytest-dev/pytest#920 which should be fixed with 3.2.0. |
I have tried that in a couple of ways but it doesn't seem to work together with the |
3f7b0f4
to9578221
Compareanntzer commentedMay 6, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Looking at the big picture, the request seems reasonable (I still need to look at the implementation carefully), but probably we need to stop pushing subplotparams on the stack when using the interactive subplottool, otherwise an enormous number of entries will be generated while moving the sliders. [Edit: actually that's not a problem, it's up to subplottool to push an entry on the stack in if it wants] Edit: The original repro script given at the top indeed shows the problem with the various builtin interactive backends, but not with mplcairo. I'll want to investigate that first, as that may just be an issue elsewhere that we'd be papering over... |
The following code show that it is a problem with the interactive navigation when
tight_layout
is True. The problem is thattight_layout
use the figures subplot parameters when calculating the new parameters (I am not really sure why, to use theaxes
positions also seems to work in the tests I have done) and those are not stored in the plot stack and thus not updated when the back, forward and home buttons are used.My solution that seems to work is to add the subplot parameters to the stack. I add the same parameters for all axis even though you don't have to but the code became clean and not much is changed in this pr.
I also added a
get function
for the subplot parameters because I want one.One issue might be that some figure don't have a subplot parameters but I don't think that it is possible.
I guess that it should be good with some tests for this interactive behavior and I am going to look into that.