yieldplotlib.plots.generic_plot#

Generic plotting utilities that work with any DirectoryNode.

This module extends matplotlib’s Axes class with methods for plotting data directly from DirectoryNode objects using key-based access.

Functions#

ypl_plot(self, directory_node, x, y[, c, autolabel])

Plot data from a DirectoryNode.

ypl_scatter(self, directory_node, x, y[, c, autolabel])

Create a scatter plot from DirectoryNode data.

ypl_hist(self, directory_node, x[, autolabel, ...])

Create a histogram from DirectoryNode data.

extend_matplotlib()

Extend matplotlib's Axes class with our DirectoryNode methods.

subplots(*args, **kwargs)

A simple wrapper around plt.subplots().

Module Contents#

yieldplotlib.plots.generic_plot.ypl_plot(self, directory_node, x, y, c=None, autolabel=True, **kwargs)[source]#

Plot data from a DirectoryNode.

Args:
self (matplotlib.axes.Axes):

The axes to plot the data on.

directory_node (DirectoryNode):

The data source to extract plotting variables from.

x (str):

Key for x-axis data.

y (str):

Key for y-axis data.

c (str, optional):

Key for color data.

autolabel (bool, optional):

Whether to automatically label the axes.

**kwargs:

Additional keyword arguments passed to the plot method.

Returns:

matplotlib.lines.Line2D: The line(s) created.

yieldplotlib.plots.generic_plot.ypl_scatter(self, directory_node, x, y, c=None, autolabel=True, **kwargs)[source]#

Create a scatter plot from DirectoryNode data.

Args:
self (matplotlib.axes.Axes):

The axes to plot the scatter on.

directory_node (DirectoryNode):

The data source to extract plotting variables from.

x (str):

Key for x-axis data.

y (str):

Key for y-axis data.

c (str or array-like, optional):

Key for color data or an array of color values.

autolabel (bool, optional):

Whether to automatically label the axes.

**kwargs:

Additional keyword arguments passed to the scatter method.

Returns:

matplotlib.collections.PathCollection: The scatter plot created.

yieldplotlib.plots.generic_plot.ypl_hist(self, directory_node, x, autolabel=True, reference_unit=None, **kwargs)[source]#

Create a histogram from DirectoryNode data.

Args:
self (matplotlib.axes.Axes):

The axes to plot the histogram on.

directory_node (DirectoryNode):

The data source to extract plotting variables from.

x (str):

Key for the data to be histogrammed.

autolabel (bool, optional):

Whether to automatically label the axes.

reference_unit (astropy.units.Unit, optional):

Reference unit to convert data to. If provided, all data will be converted to this unit before plotting. This ensures unit consistency across multiple datasets.

**kwargs:

Additional keyword arguments passed to the hist method.

Returns:

tuple: (n, bins, patches) as returned by hist

yieldplotlib.plots.generic_plot.extend_matplotlib()[source]#

Extend matplotlib’s Axes class with our DirectoryNode methods.

This automatically adds all functions with the ‘ypl_’ prefix in this file to the matplotlib Axes class, so they can be used directly on any axes.

yieldplotlib.plots.generic_plot.subplots(*args, **kwargs)[source]#

A simple wrapper around plt.subplots().

Ensures our extensions are applied before returning.

Args:

*args: Arguments to pass to plt.subplots(). **kwargs: Keyword arguments to pass to plt.subplots().

Returns:

tuple: (fig, ax) as returned by plt.subplots()