def set_dim( fig: matplotlib.figure.Figure, width: float = 398.3386, fraction_of_line_width: float = 1, ratio: float = (5 ** 0.5 - 1) / 2, ) -> None: """Set aesthetic figure dimensions to avoid scaling in latex. Default width is `src.constants.REPORT_WIDTH`. Default ratio is golden ratio, with figure occupying full page width. Args: fig (matplotlib.figure.Figure): Figure object to resize. width (float): Textwidth of the report to make fontsizes match. Defaults to `src.constants.REPORT_WIDTH`. fraction_of_line_width (float, optional): Fraction of the document width which you wish the figure to occupy. Defaults to 1. ratio (float, optional): Fraction of figure width that the figure height should be. Defaults to (5 ** 0.5 - 1)/2. Returns: void; alters current figure to have the desired dimensions Example: Here is an example of using this function:: >>> set_dim(fig, fraction_of_line_width=1, ratio=(5 ** 0.5 - 1) / 2) """ fig.set_size_inches( get_dim(width=width, fraction_of_line_width=fraction_of_line_width, ratio=ratio) )
def fig_square(fig: mpl.figure.Figure) -> None: """Adjust figure width so that it is square, and tight layout. Parameters ---------- fig : mpl.figure.Figure `Figure` instance. """ fig.set_size_inches(mpl.figure.figaspect(1)) fig.tight_layout()
def setsize(fig: matplotlib.figure.Figure) -> None: """ Set the size of a figure. Currently the size is hardcoded, but functionality may be extended in the future. Arguments --------- fig : matplotlib.figure.Figure Figure to a be saved. """ fig.set_size_inches(11.75, 8.25) # a4