Skip to content
Browse files

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

DPI has no effect on SVG figures, so any other value will result in
mismatch between svg and png figures.
  • Loading branch information...
1 parent c956c22 commit 16e17715442cee7396ff6c30f69ebca1df10a1d3 @minrk minrk committed with fperez
Showing with 6 additions and 6 deletions.
  1. +1 −3 IPython/lib/
  2. +5 −3 IPython/zmq/pylab/
4 IPython/lib/
@@ -100,9 +100,7 @@ def print_figure(fig, fmt='png'):
bytes_io = BytesIO()
- # use 72 dpi to match QTConsole's dpi
- fig.canvas.print_figure(bytes_io, format=fmt, dpi=72,
- bbox_inches='tight')
+ fig.canvas.print_figure(bytes_io, format=fmt, bbox_inches='tight')
data = bytes_io.getvalue()
8 IPython/zmq/pylab/
@@ -38,18 +38,20 @@ def _config_changed(self, name, old, new):
# The typical default figure size is too large for inline use,
# so we shrink the figure size to 6x4, and tweak fonts to
- # make that fit. This is configurable via Global.pylab_inline_rc,
- # or rather it will be once the zmq kernel is hooked up to
- # the config system.
+ # make that fit.
rc = Dict({'figure.figsize': (6.0,4.0),
# 12pt labels get cutoff on 6x4 logplots, so use 10pt.
'font.size': 10,
+ # 72 dpi matches SVG/qtconsole
+ # this only affects PNG export, as SVG has no dpi setting
+ 'savefig.dpi': 72,
# 10pt still needs a little more room on the xlabel:
'figure.subplot.bottom' : .125
}, config=True,
help="""Subset of matplotlib rcParams that should be different for the
inline backend."""
figure_format = CaselessStrEnum(['svg', 'png'], default_value='png', config=True,
help="The image format for figures with the inline backend.")

0 comments on commit 16e1771

Please sign in to comment.
Something went wrong with that request. Please try again.