Skip to content

Commit 8c3fd5e

Browse files
committed
Set the dpi with figure.dpi instead of savefig.dpi
This makes changing the dpi more straight forward and controllable within a context. For example, the code below now works as expected. ```python with mpl.rc_context(): mpl.rcParams['figure.dpi'] = 200 mpl.rcParams['figure.figsize'] = (6, 4) ax = plt.subplot(111) ax.scatter([1, 2], [1, 2]) ``` Without this commit and the accompanying commit in `ipython`, the `dpi` would be queried directly from the `rcParams` and this would happen outside the context. With this commit, Matplotlib creates a figure with the correct `dpi` as a property and `ipython` will always use that or modify it accordingly. Also by using `savefig.dpi`, the internal workings of the backend were slipping into userspace. `InlineBackend` uses the same method as used for saving but as far as the user is concerned, what is happening is an image-display not an image-save.
1 parent 3a7c48d commit 8c3fd5e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class InlineBackend(InlineBackendConfig):
5050
'font.size': 10,
5151
# 72 dpi matches SVG/qtconsole
5252
# this only affects PNG export, as SVG has no dpi setting
53-
'savefig.dpi': 72,
53+
'figure.dpi': 72,
5454
# 10pt still needs a little more room on the xlabel:
5555
'figure.subplot.bottom' : .125
5656
},

0 commit comments

Comments
 (0)