1

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?

Richard Herron
  • 9,760
  • 12
  • 69
  • 116

1 Answers1

0

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.

Alex44
  • 3,597
  • 7
  • 39
  • 56
  • Thanks! I think I am following his advice via my `rcParams['figure.dpi'] = 600` (the Jupyter Book template imports `rcParams` without the `plt` prefix). I think the difference between my question and his post is that I am building a Jupyter Book while the linked post is about single Jupyter Notebooks. – Richard Herron Sep 13 '22 at 17:18