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#
|
Plot data from a DirectoryNode. |
|
Create a scatter plot from DirectoryNode data. |
|
Create a histogram from DirectoryNode data. |
Extend matplotlib's Axes class with our DirectoryNode methods. |
|
|
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.