You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which backend are you using? Try printing from matplotlib import rcParams; print(rcParams['backend']) from your matplotilb session.
Proplot struggles with a lot of "interactive" backends because its geometry algorithm automatically resizes figures (which can trigger a backend refresh, which can trigger a figure resize... have to work around these issues very carefully).
Thanks. Just tried it out in an ipython session with %matplotlib qt and I also get very slow/laggy behavior, even though IIRC proplot used to work fine with the qt backend. These are always fun to debug...
For now if you're on mac you can also try %matplotlib osx, seems to work fine for me. And proplot usually works really well with static inline jupyter notebook/console backends.
Thanks for replying. I'm afraid I don't have a mac machine. Most of the time I don't use ipython or jupyter, but plain python in a terminal. By "static inline console backends" did you mean backends likePS, Agg, PDF? With these I can only save the image to a file, but can't display it in a window using figure.show(), can I?
Hmmm, I can't reproduce this behavior anymore... I think my "qt is laggy/frozen" observation the other day might have been due to the fact that qt is more resource intensive and I had more processes running that day. Just tried your example with qt5agg and tkagg in master and in v0.6.4 and they seems to work fine. Also I've never seen the "window shaking" behavior, could you re-upload the movie? Looks like the link is dead.
I wonder if this could be platform-specific. Maybe your OS is for some reason automatically resizing the window slightly (or were you maybe trying to manually resize the figure by clicking and dragging)? When the window changes size, proplot tries to adjust the spacing, and for figures with dense graphics (like your example) this is always going to be pretty slow. A workaround would be to use fig.subplots(..., tight=False) and set spaces manually but that's obviously not ideal.
Submitting a release soon so if this bug gets confirmed and eventually fixed it will probably go into the next minor release.
I forgot to make the repo where the video was uploaded to public. Could you try that link again and see if you can see the video?
Setting the tight=False kwarg does solve the shaking window problem, but the colorbar is put too far away. I assume that wouldn't be a viable workaround.
Wow that is... interesting. Yeah with tight=False you'd have to manually set all your spacings -- for the colorbar spacing you would use e.g. ax.colorbar(..., space='2em'), ax.colorbar(..., space=0.5), etc (see this page).
Unfortunately it looks like this is probably OS specific so will be hard for me to debug but I'll take a close look at the auto spacing algorithm. Interesting that this happens with both Qt5Agg and TkAgg.
And just to confirm, this doesn't happen in matplotlib plots with matplotlib's tight_layout algorithm enabled? Example:
importmatplotlib.pyplotaspltimportnumpyasnpif__name__=='__main__':
lons=np.arange(0, 360)
lats=np.arange(-90, 90)
lons, lats=np.meshgrid(lons, lats)
var=np.random.random(lons.shape)
fig,ax=plt.subplots()
fig.set_tight_layout(True) # adjust layout every time figure is drawncs=ax.contourf(lons, lats, var)
ax.set_title('Test')
fig.colorbar(cs)
fig.show()
FYI was able to reproduce this, but strangely, only for plots with certain content (e.g. everything was fine with 1 pcolor subplot and one empty subplot, but not 2 pcolor subplots).
Definitely on my radar but will probably take a deep dive into my whole auto sizing algorithm to figure out. Maybe 0.7.1
I've made some major changes to the internals for a v0.8 release, including improvements to the tight layout algorithm. Might be worth trying this again (try installing the dev version with pip install git+https://github.com/lukelbd/proplot.git). Haven't been able to reproduce this since the changes
I think I'll close this for now, but if anyone reading this thread experiences issues with the qt backend, please let me know and I'll be happy to reopen.
Hey! Is there any workaround solution regarding the changed auto_layout of matplotlib.pyplot after importing proplot, besides this tight_layout solution (or downgrading matplotlib)? A simple matplotlib.pyplot.plot(x) after the import still messes up the layout.
Activity
lukelbd commentedon Jun 30, 2021
Which backend are you using? Try printing
from matplotlib import rcParams; print(rcParams['backend'])from your matplotilb session.Proplot struggles with a lot of "interactive" backends because its geometry algorithm automatically resizes figures (which can trigger a backend refresh, which can trigger a figure resize... have to work around these issues very carefully).
Xunius commentedon Jul 1, 2021
I was using Qt5Agg, and I tried TkAgg which is also unstable.
lukelbd commentedon Jul 1, 2021
Thanks. Just tried it out in an ipython session with
%matplotlib qtand I also get very slow/laggy behavior, even though IIRC proplot used to work fine with the qt backend. These are always fun to debug...For now if you're on mac you can also try
%matplotlib osx, seems to work fine for me. And proplot usually works really well with static inline jupyter notebook/console backends.Xunius commentedon Jul 1, 2021
Thanks for replying. I'm afraid I don't have a mac machine. Most of the time I don't use ipython or jupyter, but plain python in a terminal. By "static inline console backends" did you mean backends like
PS,Agg,PDF? With these I can only save the image to a file, but can't display it in a window usingfigure.show(), can I?lukelbd commentedon Jul 1, 2021
I meant backends used in jupyter notebooks and consoles. Looks something like this:
Will try to get on this, proplot should definitely work with the basic popup backends used when running naked python scripts.
[-]Figure window keeps on shaking and python freezes[/-][+]Issues with popup qtagg and tkagg backends[/+]lukelbd commentedon Jul 4, 2021
Hmmm, I can't reproduce this behavior anymore... I think my "qt is laggy/frozen" observation the other day might have been due to the fact that qt is more resource intensive and I had more processes running that day. Just tried your example with qt5agg and tkagg in master and in v0.6.4 and they seems to work fine. Also I've never seen the "window shaking" behavior, could you re-upload the movie? Looks like the link is dead.
I wonder if this could be platform-specific. Maybe your OS is for some reason automatically resizing the window slightly (or were you maybe trying to manually resize the figure by clicking and dragging)? When the window changes size, proplot tries to adjust the spacing, and for figures with dense graphics (like your example) this is always going to be pretty slow. A workaround would be to use
fig.subplots(..., tight=False)and set spaces manually but that's obviously not ideal.Submitting a release soon so if this bug gets confirmed and eventually fixed it will probably go into the next minor release.
Xunius commentedon Jul 5, 2021
I forgot to make the repo where the video was uploaded to public. Could you try that link again and see if you can see the video?
Setting the
tight=Falsekwarg does solve the shaking window problem, but the colorbar is put too far away. I assume that wouldn't be a viable workaround.lukelbd commentedon Jul 5, 2021
Wow that is... interesting. Yeah with
tight=Falseyou'd have to manually set all your spacings -- for the colorbar spacing you would use e.g.ax.colorbar(..., space='2em'),ax.colorbar(..., space=0.5), etc (see this page).Unfortunately it looks like this is probably OS specific so will be hard for me to debug but I'll take a close look at the auto spacing algorithm. Interesting that this happens with both
Qt5AggandTkAgg.And just to confirm, this doesn't happen in matplotlib plots with matplotlib's
tight_layoutalgorithm enabled? Example:Xunius commentedon Jul 6, 2021
Yes I can confirm that this doesn't happen to plain matplotlib plot with tight_layout on.
lukelbd commentedon Jul 12, 2021
FYI was able to reproduce this, but strangely, only for plots with certain content (e.g. everything was fine with 1
pcolorsubplot and one empty subplot, but not 2pcolorsubplots).Definitely on my radar but will probably take a deep dive into my whole auto sizing algorithm to figure out. Maybe 0.7.1
Xunius commentedon Jul 12, 2021
Thanks for the update. Looking forward to seeing the new version.
lukelbd commentedon Aug 18, 2021
I've made some major changes to the internals for a v0.8 release, including improvements to the tight layout algorithm. Might be worth trying this again (try installing the dev version with
pip install git+https://github.com/lukelbd/proplot.git). Haven't been able to reproduce this since the changeslukelbd commentedon Jan 24, 2022
I think I'll close this for now, but if anyone reading this thread experiences issues with the qt backend, please let me know and I'll be happy to reopen.
MarlenK7 commentedon Jul 10, 2023
Hey! Is there any workaround solution regarding the changed auto_layout of matplotlib.pyplot after importing proplot, besides this tight_layout solution (or downgrading matplotlib)? A simple matplotlib.pyplot.plot(x) after the import still messes up the layout.

Versions: matplotlib 3.4.3 / proplot 0.9.7