question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Does %matplotlib notebook supposed to work?

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mickaellalandecommented, Dec 3, 2019

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):

proplot_notebook

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!

1reaction
lukelbdcommented, Dec 18, 2019

I fixed this and released a new version on PyPi. Run

pip install --upgrade proplot

To use the notebook backend, you can use %matplotlib notebook, but that will bypass some useful things that ipython_matplotlib does to keep the style the same as the inline backend, so I recommend using

import proplot as plot
plot.rc.matplotlib = 'notebook'  # option 1
# plot.ipython_matplotlib('notebook')  # option 2

or adding the line matplotlib: notebook to the .proplotrc file that should have been automatically created in your home directory.

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Visualization with Matplotlib | Python Data Science Handbook
Matplotlib is a multi-platform data visualization library built on NumPy arrays, and designed to work with the broader SciPy stack.
Read more >
Using %matplotlib notebook after %matplotlib inline in Jupyter ...
In first cell with my code I have a magic command %matplotlib inline and after this magic command I run my code, everything...
Read more >
Using matplotlib in jupyter notebooks — comparing methods ...
This is just a quick post because I didn't find one place that collects all the options and compares those as well as...
Read more >
Does %matplotlib notebook supposed to work? #76 - GitHub
The notebook backend is a special case I think -- it internally tries to resize the figure, which triggers a redraw, which itself...
Read more >
Making Plots in Jupyter Notebook Beautiful & More Meaningful
pyplot function can be made to create a figure, create a plotting area in a figure, plot some lines in a plotting area,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found