serpentTools.utils.plot.formatPlot

serpentTools.utils.plot.formatPlot(ax, xlabel=None, ylabel=None, logx=False, logy=False, loglog=False, title=None, legend=True, legendcols=1, axkwargs=None, legendkwargs=None)

Apply a range of formatting options to the plot.

Parameters
  • ax (matplotlib.axes.Axes, optional) – Ax on which to plot the data. If not provided, create a new plot

  • xlabel (str or bool, optional) – Label to apply to the x-axis. If given as None, a label will be determined from other arguments. If not None but evaluates to False, do not label.

  • ylabel (str or bool, optional) – Label to apply to the y-axis. If given as None, a label will be determined from other arguments. If not None but evaluates to False, do not label.

  • loglog (bool) – Apply a log scale to both axes.

  • logx (bool) – Apply a log scale to x axis.

  • logy (bool) – Apply a log scale to y axis.

  • title (str, optional) – Title to apply to this axes object

  • legend (bool or str or None) – Automatically label the plot. No legend will be made if a single item is plotted. Pass one of the following values to place the legend outside the plot: above, right

  • legendcols (int, optional) – Number of columns to apply to the legend, if applicable

  • axkwargs (dict, optional) – Additional keyword arguments to be passed to matplotlib.axes.Axes.set(). Values like xlabel, ylabel, xscale, yscale, and title will be respected, even though they are also arguments to this function

  • legendkwargs (dict, optional) – Additional keyword arguments to be passed to matplotlib.axes.Axes.legend(). Values like title and ncol will be respected.

Returns

Ax on which the data was plotted.

Return type

matplotlib.axes.Axes

Raises

TypeError – If the ax argument is not an instance of matplotlib.pyplot.axes.Axes