lib5c.util.plotting module

Module containing utilities related to plotting.

lib5c.util.plotting.adjust_plot(ax=None, xlim=None, ylim=None, xlabel=None, ylabel=None, xticks=None, yticks=None, title=None, despine=True, legend=None)[source]

Multipurpose plot adjustment method.

Parameters
  • ax (pyplot axis) – The axis to operate on.

  • xlim (tuple of numeric) – Pass a tuple of the form (min, max) to set the x-limits of the plot.

  • ylim (tuple of numeric) – Pass a tuple of the form (min, max) to set the y-limits of the plot.

  • xlabel (str) – Label for the x-axis.

  • ylabel (str) – Label for the y-axis.

  • xticks (int, list of int, or tuple of list of ints) – Pass an int to use this as the spacing for the xticks. Pass a (positions, labels) tuple to call plt.xticks(positions,labels). Pass anything else to pass it directly to plt.xticks().

  • yticks (int, list of int, or tuple of list of ints) – Pass an int to use this as the spacing for the yticks. Pass a (positions, labels) tuple to call plt.yticks(positions,labels). Pass anything else to pass it directly to plt.yticks().

  • title (str) – Title for the plot.

  • despine (bool) – Pass True to despine the plot.

  • legend (str or bool or None) – Pass False to remove the legend, pass True to add a default legend, pass ‘outside’ to move the legend outside the plot area, pass None to leave the legend alone.

lib5c.util.plotting.compute_hexbin_extent(xlim, ylim, logx=False, logy=False)[source]

Helper function for computing the extent kwarg of plt.hexbin().

Parameters
  • ylim (xlim,) – Tuple of (x_min, x_max) and (y_min, y_max), respectively. If either is None, no attempt will be made to set the extent.

  • logy (logx,) – Whether or not plt.hexbin() is being called with xscale='log' and/or yscale='log', respectively.

Returns

The extent if it could be computed or None otherwise.

Return type

list or None