How do I increase the resolution of Matplotlib plots in Jupyter Book?

1.1k Views Asked by At

I typically use plt.rcParams['figure.dpi'] = 300 to increase the resolution of Matplotlib plots in my Jupyter notebooks. However, this setting does not seem to work with Jupyter Books. Here are reproducible steps:

  1. Create a Jupyter Book template with jupyter-book create mynewbook
  2. To mynewbook/notebooks.ipynb, add a code cell with rcParams['figure.dpi'] = 600 just before the plot
  3. Build this Jupyter Book with jupyter-book build --builder pdflatex mynewbook

The figure in notebooks.ipynb remains the default resolution (72 dpi?) instead of 600 dpi, even though the in-notebook resolution is 600 dpi. How can I increase the resolution of Matplotlib (and seaborn) plots in Jupyter Books?

1

There are 1 best solutions below

1
Alex44 On

In this post the author proposes to increase the resolution:

from matplotlib import pyplot
pyplot.rcParams['figure.dpi'] = 600
pyplot.rcParams['savefig.dpi'] = 600

This works for me.