ipython / ipython/matplotlib-inline

Retina+jpeg option?

未關閉
#5 5 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Jupyter Notebook
星號
31
分支
39
PR 合併指標
30 天內沒有已合併 PR

描述

I often work with complex matplotlib figures with millions of points, which I've been displaying in my notebooks using the ipython magic `%config InlineBackend.figure_format = 'retina'`. Unfortunately, these inline images are quite large in terms of file size.

I'm looking for general suggestions on how to reduce the size of my ipynb files, which can grow into the 10s or even hundreds of MB in size and become a bit unwieldy.

One thought I had was to switch to generating jpegs, but while it looks like I can meaningfully reduce the file size by switching the backend to jpeg and increasing the dpi to 2x:

```python
from matplotlib import rcParams
%config InlineBackend.figure_format = 'jpeg'
rcParams['figure.dpi'] = 200
```

From this repo, it looks like I can dial in jpeg compression values, which should help reduce file size. However, I can't figure out how to size the jpegs appropriately for a retina display (they're twice as large as they should be, and slightly blurry). Is there a way to display jpegs in jupyter notebooks at similar resolution and size to the defaults provided by `'retina'` mode?

See also:
[Matplotlib issue](https://github.com/matplotlib/matplotlib/issues/20697)
[Stackoverflow question](https://stackoverflow.com/questions/68429854/reduce-file-size-of-matplotlib-images-in-jupyter-notebooks)

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。