Jupyter not displaying SVG plots after reopening notebook
- Dominant language
- Jupyter Notebook
- Stars
- 13.3k
- Forks
- 5.8k
- Avg merge
- 6d 11h
- Merged PRs (30d)
- 7
Description
I have now observed this multiple times yet it is impossible to reproduce because it only happens for some of my notebooks, seemingly arbitrarily: when I produce Matplotlib plots in a Jupyter notebook using `%matplotlib inline` and `plt.show` they are displayed correctly, but in some cases shutting down the notebook server, restarting it and then reopening the notebook causes the plots to be replaced by placeholders of the form ``.
This only seems to happen when I use `set_matplotlib_formats('svg')` (which I imagine is a common setting) and as mentioned not for every notebook (but for all images in a notebook if it does happen).
I'm using anaconda, `jupyter --version` is `4.4.0, `jupyter notebook --version` is ` 5.4.0, `python --version` is `3.6.8` and `matplotlib.__version__` is `'2.2.3'`. This happens for both Chrome and Firefox
This essentially makes Jupyter unuseable for me so I was surprised that I could not find an issue bringing this up. Is this a known issue? Or maybe even intended? Or am I doing something wrong here?
I'll attach the saved output of a cell which should display an SVG image but doesn't (I can't share the whole notebook and as I mentioned I can't seem to produce a minimal example).
```
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"W, b = init_params(d, K)\n",
"\n",
"plt.hist(W.flatten())\n",
"\n",
"plt.title(\"Initial Weight Value Distribution\")\n",
"\n",
"plt.savefig(os.path.join(FIGURE_DIR, 'initial_weights.svg'))"
]
},
```
Contributor guide
Research direction
Start with the attached saved cell output and the reported Jupyter 4.4.0, Notebook 5.4.0, Python 3.6.8, and Matplotlib 2.2.3 versions. Reproduce the restart-and-reopen sequence with `%matplotlib inline`, `plt.show`, and `set_matplotlib_formats('svg')`; done means reopened notebooks render the SVG plots instead of the Figure placeholder.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jupyter-notebook, python
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100