yieldplotlib.plots.generic_plot
===============================

.. py:module:: yieldplotlib.plots.generic_plot

.. autoapi-nested-parse::

   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
---------

.. autoapisummary::

   yieldplotlib.plots.generic_plot.ypl_plot
   yieldplotlib.plots.generic_plot.ypl_scatter
   yieldplotlib.plots.generic_plot.ypl_hist
   yieldplotlib.plots.generic_plot.extend_matplotlib
   yieldplotlib.plots.generic_plot.subplots


Module Contents
---------------

.. py:function:: ypl_plot(self, directory_node, x, y, c=None, autolabel=True, **kwargs)

   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.


.. py:function:: ypl_scatter(self, directory_node, x, y, c=None, autolabel=True, **kwargs)

   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.


.. py:function:: ypl_hist(self, directory_node, x, autolabel=True, reference_unit=None, **kwargs)

   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


.. py:function:: extend_matplotlib()

   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.


.. py:function:: subplots(*args, **kwargs)

   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()


