-
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 with auto_update=True
in Jupyter notebooks with %matplotlib ipympl
results in a busy kernel
#2247
Labels
Comments
Currently the gridlines are removed before recreating them, so there is a lot of thrashing going on for you with draw() / remove() both trying to continuously update. cartopy/lib/cartopy/mpl/gridliner.py Lines 627 to 639 in 60c8c20
It would be great if someone wanted to contribute a way to just update the current gridlines that are already present rather than needing to remove the gridlines and labels. |
This was referenced Sep 22, 2023
mx-moth
added a commit
to csiro-coasts/emsarray
that referenced
this issue
Sep 27, 2023
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
mx-moth
added a commit
to csiro-coasts/emsarray
that referenced
this issue
Sep 27, 2023
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
Hi @mx-moth, please could you try your use-case again with Cartopy 0.23?
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
Not exactly sure what words to use to describe this issue.
If I set up a Jupyter lab environment with the following code and generate a plot, the kernel flickers between Idle and Busy for as long as the plot is drawn as an output of a cell. For simple plots this just causes some unnecessary flickering, but for more complicated plots this can cause considerable slow down.
The flickering is noticeable in the top-right kernel indicator and in the status bar. I think the flickering is associated with redrawing the plot constantly. For more complicated plots, the plot becomes impossible to interact with because it spends much more time busy than it does idle, and a busy plot is not interactable.
Removing
auto_update=True
from theaxes.gridlines()
stops the flickering, but also stops the gridlines automatically updating.Code to reproduce
Set up a conda environment and launch Jupyter lab. The
emsarray
dependency is for a later demonstration of a more complicated plot:Make a new notebook and add the following code:
To generate a more complicated plot to better show a busy plot being non-interactive, construct a more complicated PolyCollection:
If
auto_update=True
is removed fromaxes.gridlines()
the kernel is no longer permanently busy. The plot responds to mouse movements by updating the coordinates quickly. (If you drag the map the plot takes a while to rerender, but this is expected because the plot geometry is complicated)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: