-
Notifications
You must be signed in to change notification settings - Fork 367
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
Using Gridliner in Jupyter notebooks with %matplotlib inline
crashes
#2246
Comments
I think the problem is here: cartopy/lib/cartopy/mpl/geoaxes.py Lines 490 to 491 in 60c8c20
This method is called within So one way to fix this would be to not remove and re-create all the labels, as suggested at #2247 (comment). |
matplotlib/matplotlib#26899 also fixes this. |
There are currently a number of problems with gridlines on plots in Jupyter notebooks. There are different solutions that depend on whether you want an interactive plot, a static plot in a notebook, or are saving the plot to a file. Unfortunately there is no single solution that works in all cases currently. Until a proper solution is found, users can disable gridlines and then re-enable them in the way that works for their current environment. SciTools/cartopy#2245 SciTools/cartopy#2246 SciTools/cartopy#2247
There are currently a number of problems with gridlines on plots in Jupyter notebooks. There are different solutions that depend on whether you want an interactive plot, a static plot in a notebook, or are saving the plot to a file. Unfortunately there is no single solution that works in all cases currently. Until a proper solution is found, users can disable gridlines and then re-enable them in the way that works for their current environment. SciTools/cartopy#2245 SciTools/cartopy#2246 SciTools/cartopy#2247
Thanks for fixing this! |
Description
I am attempting to make some plots in Jupyter notebooks using matplotlib and cartopy. I would like to include geoaxes on these. Adding the following code to a notebook will throw an error.
Code to reproduce
Set up a fresh conda environment, install the required libraries, and run jupyter-lab
Make a new notebook and add this code:
The error is not present if I change any of the following:
draw_labels=[...]
parameter toaxes.gridlines()
. However I need grid labels here.auto_update=True
parameter toaxes.gridlines()
.auto_update=True
is useful for interactive backends though, so I'd prefer to keep it enabled. If there was some good way of detecting interactive backends I could update the code to use that instead of defaulting to True. However even with%matplotlib inline
,matplotlib.pyplot.isinteractive()
returns True.Traceback
Full environment definition
Operating system
Ubuntu 20.04
Cartopy version
0.22.0
conda list
The text was updated successfully, but these errors were encountered: