Skip to content

Retina+jpeg option in jupyter #20697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nspies-celsiustx opened this issue Jul 20, 2021 · 3 comments
Closed

Retina+jpeg option in jupyter #20697

nspies-celsiustx opened this issue Jul 20, 2021 · 3 comments

Comments

@nspies-celsiustx
Copy link

Problem

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.

Proposed Solution

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:

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

I can't figure out how to size them 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?

Additional context and prior art

(Moved here from this question on stackoverflow.)

@jklymak
Copy link
Member

jklymak commented Jul 20, 2021

This is an ipython configuration, and should be discussed on one of their channels.

I doubt you will get any substantial improvements from jpg over png. You will either have to drop to 100 dpi (for a factor of 4 drop) or manage your notebooks so they do not have so many figures in them.

I'm going to close this here.

@nspies-celsiustx
Copy link
Author

nspies-celsiustx commented Jul 20, 2021

This is an ipython configuration, and should be discussed on one of their channels.

Do you know where this configuration lives (ie which repo)? Happy to open an issue there, but it's hard to understand how the different parts of the ecosystem take care of these things.

@jklymak
Copy link
Member

jklymak commented Jul 20, 2021

https://github.com/ipython/matplotlib-inline

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants