Closed megies closed 6 years ago
@krischer Another way to approach this might be to put a matplotlibrc
file on the server, so that nbagg
backend is used all across seismo-live globally (would also allow for setting proper default figure size etc.). Only drawback might be that then when users download the notebooks, they might behave a bit differently locally..
I actually just realized that the agg
instead of the nbagg
backend was forced in the Dockerfile...fixed in https://github.com/krischer/seismo_live/commit/8a3b68dcf9c82e8e82f051b7ce1eb8efd2965da9. Should be live at the next restart of seismo-live.
As @heinerigel encountered, some animations in some notebooks are broken when using very recent Anaconda (due to changes in Jupyter and/or Matplotlib, likely).
For example, try https://github.com/krischer/seismo_live/blob/master/notebooks/Computational%20Seismology/The%20Finite-Difference%20Method/fd_elastic1d_staggered_solution.ipynb on current seismo-live server. Animation does not show and is stuck on first plot.
It looks like using the convenience function
plt.switch_backend('nbagg')
isn't doing the job anymore and the problem is solved by doing it the "old" canonical/failsafe way, by usingmatplotlib.use('nbagg')
as the first command after a plainimport matplotlib
at top of the code when no backend is yet selected by matplotlib, to avoid problems with backend switching.If you take the first cell of that notebook, which currently loos like this and doesn't work:
Changing it like this works:
Using IPython "magic" command also works:
It's mostly a matter of taste which one is used. But the
matplotlib.use()
option has the pro that if downloading the notebook as plain Python code, the backend can be changed totkagg
in thematplotlib.use()
call and then the code also runs when executing the Python program outside of Jupyter.CC @heinerigel @krischer