def set_figure_params(dpi=None, figure_formats=['png2x']):
"""Set resolution and format of figures.
Parameters
----------
dpi : int, optional
Resolution of png output in dots per inch.
figure_formats : list of strings
Only concerns the IPython environment; see
`IPython.core.display.set_matplotlib_formats` for more details. For
setting the default format for saving figures, directly set
`file_format_figs`.
"""
try:
import IPython
IPython.core.display.set_matplotlib_formats(*figure_formats)
except:
pass
from matplotlib import rcParams
global _dpi
if dpi is not None: _dpi = dpi
# need to set the following two lines as older Jupyter notebooks seem to use
# 'savefig.dpi' and more rescent ones 'figure.dpi'
rcParams['savefig.dpi'] = _dpi
rcParams['figure.dpi'] = _dpi
评论列表
文章目录