This answer from a few years ago shows how you can make jupyter notebook create graphs like svg. The solution is to tell InlineBackend to use svg as output.
import matplotlib.pyplot as plt %matplotlib inline %config InlineBackend.figure_format = 'svg' plt.plot(...)
This will cause all images to be in svg format inside the laptop, as well as in the created ipynb file; the file will have a line like
"data": { "image/svg+xml": [ "<?xml .....
in him.
The problem is that this does not work if the backend is %matplotlib notebook . %config InlineBackend doesnβt change anything for the backend laptop, so the output file contains a PNG image
"data": { "text/html": [ "<img src=\"data:image/png;base64,iVBORw0....
So the question is: How do I get an ipynb file to include a static version of a graph created using %matplotlib notebook backend as an SVG image?
From a month ago, there is a small comment by @mark jay who wanted to do exactly what I would like to do now, but there is no answer or a hint of this comment.
In my code, I built directly from the data frame:
%matplotlib notebook import pandas as pd df = pd.read_sql(sql1, connection) ... ... df.plot(subplots=True, kind='bar')
This works fine without importing matplotlib.pyplot , but it also cannot be forced to create a graphic like svg. I believe that if the base case worked, I could change the build code, so it did not include pandas or dataframes.
python matplotlib pandas jupyter-notebook
cardamom
source share