Skip to content
This repository

allow change of png DPI in inline backend #957

Closed
wants to merge 1 commit into from

2 participants

Min RK Fernando Perez
Min RK
Owner

This moves setting the DPI to the rcParams initialization,
so that it can be changed later by the user, setting
rcParams['savefig.figsize'].

DPI has no effect on SVG figures, so any other value will result in
mismatch between svg and png figures. There is already a mismatch in the notebook, where 72 is not the right answer.

Min RK allow change of PNG DPI in inline backend
This moves setting the DPI to the rcParams initialization,
so that it can be changed later by the user, setting
`rcParams['savefig.figsize']`.

DPI has no effect on SVG figures, so any other value will result in
mismatch between svg and png figures.
38f62b0
Fernando Perez
Owner

Great, thanks! Rebased to prevent recursive merge on a single commit, pushed as 16e1771.

Fernando Perez fperez closed this November 10, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Oct 31, 2011
Min RK allow change of PNG DPI in inline backend
This moves setting the DPI to the rcParams initialization,
so that it can be changed later by the user, setting
`rcParams['savefig.figsize']`.

DPI has no effect on SVG figures, so any other value will result in
mismatch between svg and png figures.
38f62b0
This page is out of date. Refresh to see the latest.
4  IPython/lib/pylabtools.py
@@ -100,9 +100,7 @@ def print_figure(fig, fmt='png'):
100 100
     fig.set_edgecolor('white')
101 101
     try:
102 102
         bytes_io = BytesIO()
103  
-        # use 72 dpi to match QTConsole's dpi
104  
-        fig.canvas.print_figure(bytes_io, format=fmt, dpi=72,
105  
-                                bbox_inches='tight')
  103
+        fig.canvas.print_figure(bytes_io, format=fmt, bbox_inches='tight')
106 104
         data = bytes_io.getvalue()
107 105
     finally:
108 106
         fig.set_facecolor(fc)
8  IPython/zmq/pylab/backend_inline.py
@@ -38,18 +38,20 @@ def _config_changed(self, name, old, new):
38 38
 
39 39
     # The typical default figure size is too large for inline use,
40 40
     # so we shrink the figure size to 6x4, and tweak fonts to
41  
-    # make that fit.  This is configurable via Global.pylab_inline_rc,
42  
-    # or rather it will be once the zmq kernel is hooked up to
43  
-    # the config system.
  41
+    # make that fit.
44 42
     rc = Dict({'figure.figsize': (6.0,4.0),
45 43
         # 12pt labels get cutoff on 6x4 logplots, so use 10pt.
46 44
         'font.size': 10,
  45
+        # 72 dpi matches SVG/qtconsole
  46
+        # this only affects PNG export, as SVG has no dpi setting
  47
+        'savefig.dpi': 72,
47 48
         # 10pt still needs a little more room on the xlabel:
48 49
         'figure.subplot.bottom' : .125
49 50
         }, config=True,
50 51
         help="""Subset of matplotlib rcParams that should be different for the
51 52
         inline backend."""
52 53
     )
  54
+
53 55
     figure_format = CaselessStrEnum(['svg', 'png'], default_value='png', config=True,
54 56
         help="The image format for figures with the inline backend.")
55 57
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.