Permalink
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
`rcParams['savefig.figsize']`.

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 b131150 commit 38f62b0dca164c5bcffc2a9fe821d28728dfc1a0 @minrk committed Oct 31, 2011
Showing with 6 additions and 6 deletions.
  1. +1 −3 IPython/lib/pylabtools.py
  2. +5 −3 IPython/zmq/pylab/backend_inline.py
@@ -100,9 +100,7 @@ def print_figure(fig, fmt='png'):
fig.set_edgecolor('white')
try:
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()
finally:
fig.set_facecolor(fc)
@@ -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 38f62b0

Please sign in to comment.