reVReports.utilities.plots.format_graph#

format_graph(graph, xmin=None, xmax=None, ymin=None, ymax=None, xlabel=None, ylabel=None, autoscale_to_other_axis=False, x_formatter=<matplotlib.ticker.StrMethodFormatter object>, y_formatter=<matplotlib.ticker.StrMethodFormatter object>, legend_frame_on=False, move_legend_outside=False, drop_legend=False, title=None, legend_title=None)[source]#

Formatter for single seaborn plots. Does not work for facet plots or seaborn.objects.Plots.

Parameters:
  • graph (matplotlib.axes.Axes) – (sub-)Plot axes of matplotlib image, created by seaborn (e.g., seaborn.Boxplot).

  • xmin (float, optional) – Minimum x-value to display. By default None, which will have no effect on the graph.

  • xmax (float, optional) – Maximum x-value to display. By default None, which will have no effect on the graph.

  • ymin (float, optional) – Minimum y-value to display. By default None, which will have no effect on the graph.

  • ymax (float, optional) – Maximum y-value to display. By default None, which will have no effect on the graph.

  • xlabel (str, optional) – Label to use for the x-axis, by default None which will result in no x-axis label.

  • ylabel (str, optional) – Label to use for the y-axis, by default None which will result in no y-axis label.

  • autoscale_to_other_axis (bool, optional) – If True, and the limits of one of the axes is changed (e.g., using xmax or ymax, etc.), the other axis will be rescaled to adjust to the subset of data displayed in the graph.

  • x_formatter (matplotlib.ticker.StrMethodFormatter, optional) – Formatter to use for x-axis ticks. Default is ticker.StrMethodFormatter(“{x:,.0f}”), which will use commas for thousands. Specify None to apply no formatting.

  • y_formatter (matplotlib.ticker.StrMethodFormatter, optional) – Formatter to use for y-axis ticks. Default is ticker.StrMethodFormatter(“{x:,.0f}”), which will use commas for thousands. Specify None to apply no formatting.

  • legend_frame_on (bool, optional) – If True, and there is a legend, it will include a legend frame (i.e., outline). By default False, which hides the legend frame.

  • move_legend_outside (bool, optional) – If True and there is a legend, move the legend outside the plot (to the right side of the plot, centered vertically). By default False, which leaves the legend position unchanged.

  • drop_legend (bool, optional) – If True and there is a legend, the legend will be removed/hidden. By default False, which leaves the legend visible.

  • title (str, optional) – Title to use for the graph. By default None, which displays no title.

  • legend_title (str, optional) – Title to use for the legend. By default None, which leaves the legend title unchanged.

Returns:

matplotlib.axes.Axes – Formatted graph.