# -*- coding: utf-8 -*-# plotting.pyimportmatplotlibimportmatplotlib.pyplotasplttry:# increase the limit for the warning to pop upmatplotlib.rcParams["figure.max_open_warning"]=50exceptTypeError:# ignore the error with Sphinxpass
[docs]definitFigure(fig,width=80,aspectRatio=4.0/3.0,quiet=False):mmInch=25.4fig.set_size_inches(width/mmInch,width/aspectRatio/mmInch)w,h=fig.get_size_inches()ifnotquiet:print("initFigure() with ({w:.1f}x{h:.1f}) mm".format(w=w*mmInch,h=h*mmInch))returnfig
[docs]defcreateFigure(width=80,aspectRatio=4.0/3.0,quiet=False,**kwargs):"""output figure width in mm"""fig=plt.figure(# tight_layout=dict(pad=0.05),**kwargs)initFigure(fig,width,aspectRatio,quiet)returnfig