It would be great if there was an easy option to save Jupyter cell output to .png files.
Let’s say I have:
import matplotlib.pyplot as plt
x= range(0,10)
fig, ax = plt.subplots()
ax.plot(x, x)
plt.show()
In this example, I could use fig.savefig("img/foo.png")
, however this syntax is tied to Matplotlib, and there are many other libraries that produce images in Jupyter. In my most comfortable scenario, one would only have to add the cell magic %%capture_png img/foo.png
which would work for any library. Memorize it once, use it everywhere.
There was a similar discussion (Is there a way to save the output of a cell? - #8 by George_Gaines) already two years ago, which was suggesting the %%capture
command (@mgeier) and the project GitHub - nteract/scrapbook: A library for recording and reading data in notebooks.. But with both approaches did not solve the problem.
Currently, I am using a cumbersome workaround to extract all images from the Jupyter notebook while running the notebook (can be seen here: matplotlib - Jupyter Notebook: automatically saves all images - Stack Overflow)
Maybe by 2021 there is a new solution? Or would it be possible to make this a new Jupyter feature?