def plot_multi_format(plot_funcs, plot_kwargs=None,
usetex=False, outdir='plots',
setting_funcs=['single', 'span', 'slides', 'thumbnails']):
"""
Outputs plots formatted 4 ways: Publication ready (narrow and wide),
PowerPoint ready, and png thumbnails.
input
-----
plot_funcs : List of functions that return a mpl figure and a filename (or list of figures and filenames)
"""
setting_dict = {'single': mpl_single_column,
'span': mpl_span_columns,
'slides': mpl_slides,
'thumbnails': mpl_thumbnails}
if not os.path.exists(outdir):
os.makedirs(outdir)
# For python 3.4
# os.makedirs(outdir, exist_ok=True)
if plot_kwargs is None:
plot_kwargs=[{}]*len(plot_funcs)
for key in setting_funcs:
setting_dict[key](usetex=usetex)
for plot_func,pkwargs in zip(plot_funcs,plot_kwargs):
figs, names = plot_func(**pkwargs)
for fig,name in zip(figs,names):
fig.savefig(os.path.join(outdir, key+'_'+name))
plt.close('all')
评论列表
文章目录