-
Notifications
You must be signed in to change notification settings - Fork 96
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
Does %matplotlib notebook supposed to work? #76
Comments
This is a known issue (#62) -- the ProPlot tight layout algorithm sets the figure size automatically, so when you manually resize with interactive backends it gets instantly "snapped back" into place by the algorithm. In an upcoming patch (v0.1.4) I will have |
For justification of why ProPlot sets the figure size automatically, see this page. |
Just tried out import proplot as plot
%matplotlib notebook
ref = 1
f, axs = plot.subplots(ref=ref, nrows=3, ncols=3, aspect=1, axwidth=1.1, wratios=(3,2,2), share=0)
axs[ref-1].format(title='reference axes', titleweight='bold', titleloc='uc', titlecolor='red9')
axs[4].format(title='title\ntitle\ntitle', suptitle='Tight layout with simple grids')
axs[1].format(ylabel='ylabel\nylabel\nylabel')
axs[:4:2].format(xlabel='xlabel\nxlabel\nxlabel')
axs.format(rowlabels=['Row 1', 'Row 2', 'Row 3'], collabels=['Column 1', 'Column 2', 'Column 3']) The notebook backend is a special case I think -- it internally tries to resize the figure, which triggers a redraw, which itself triggers a resize, ad infinitum. Looks terrible. This issue has high priority. |
I fixed this and released a new version on PyPi. Run pip install --upgrade proplot To use the notebook backend, you can use import proplot as plot
plot.rc.matplotlib = 'notebook' # option 1
# plot.ipython_matplotlib('notebook') # option 2 or adding the line Note that the tight layout algorithm and automatic figure rescaling must be automatically disabled for this backend... unfortunately I could not find any obvious workaround. The inline notebook backend is "special". Also note that the performance is not great when you have figure "super titles" or row/column labels on... I think this will be improved when #50 and #46 are done. |
Thanks for the quick fix! I have just updated ProPlot and it works already, just cutting some side of the color bar in my example (I guess that's what you are mentioning): import xarray as xr
import proplot as plot
plot.rc.matplotlib = 'notebook'
da = xr.open_dataarray('snc_LImon_IPSL-CM6A-LR_historical_r1i1p1f1_gr_185001.nc')
f, axs = plot.subplots(proj='cyl', proj_kw={'lon_0':180}, axwidth=7)
axs.format(
geogridlinewidth=0.7, geogridcolor='gray8', geogridalpha=0.5, labels=True,
coast=True, abc=True, abcstyle='a.'
)
m = axs[0].contourf(da, cmap='viridis')
f.colorbar(m, label='%') File: snc_LImon_IPSL-CM6A-LR_historical_r1i1p1f1_gr_185001.zip PS: I have just discovered your package yesterday and I am impressed with it so far (more convenient and improving the existing matplolib/cartopy that I am used to)! Thanks for this great work! |
FYI @lukelbd , |
@bradyrx This is now addressed in the README and install page. |
I am used to work with
%matplotlib notebook
in my notebooks to be able to navigate in the plots (zoom, etc.). But I realized that if I put%matplotlib notebook
, the ProPlot plots do not show up and I need to come back to%matplotlib inline
to make it work again. I am doing something wrong or is this supposed to work for ProPlot too? And if not, is this planned to be working in the future?The text was updated successfully, but these errors were encountered: