yieldplotlib
============

.. py:module:: yieldplotlib

.. autoapi-nested-parse::

   yieldplotlib - A library for plotting yield data.



Submodules
----------

.. toctree::
   :maxdepth: 1

   /autoapi/yieldplotlib/accessibility/index
   /autoapi/yieldplotlib/core/index
   /autoapi/yieldplotlib/datasets/index
   /autoapi/yieldplotlib/generate_docs/index
   /autoapi/yieldplotlib/generate_key_map/index
   /autoapi/yieldplotlib/key_map/index
   /autoapi/yieldplotlib/load/index
   /autoapi/yieldplotlib/logger/index
   /autoapi/yieldplotlib/pipeline/index
   /autoapi/yieldplotlib/plots/index
   /autoapi/yieldplotlib/style/index
   /autoapi/yieldplotlib/util/index
   /autoapi/yieldplotlib/ypl_cli/index


Attributes
----------

.. autoapisummary::

   yieldplotlib.KEY_MAP
   yieldplotlib.logger
   yieldplotlib.ypl_cmap
   yieldplotlib.ypl_colors
   yieldplotlib.ypl_cycler
   yieldplotlib.ypl_rainbow


Functions
---------

.. autoapisummary::

   yieldplotlib.fetch_ayo_data
   yieldplotlib.fetch_exosims_data
   yieldplotlib.fetch_yip_data
   yieldplotlib.compare
   yieldplotlib.multi
   yieldplotlib.panel
   yieldplotlib.xy_grid
   yieldplotlib.subplots
   yieldplotlib.calculate_axis_limits_and_ticks
   yieldplotlib.get_nice_number


Package Contents
----------------

.. py:function:: fetch_ayo_data()

   Fetch and unpack AYO data.


.. py:function:: fetch_exosims_data()

   Fetch and unpack EXOSIMS data.


.. py:function:: fetch_yip_data()

   Fetch and unpack YIP data.


.. py:data:: KEY_MAP

.. py:data:: logger

.. py:function:: compare(ax, directories, x, y=None, plot_type='scatter', labels=None, colors=None, markers=None, linestyles=None, legend=True, **kwargs)

   Plot data from multiple directories on a single axes.

   Args:
       ax (matplotlib.axes.Axes):
           The axes to plot on.
       directories (list):
           List of DirectoryNode objects to plot.
       x (str):
           Key for x-axis data.
       y (str):
           Key for y-axis data.
       plot_type (str, optional):
           Type of plot to create. Options are 'scatter', 'plot', or 'hist'.
           Default is 'scatter'.
       labels (list, optional):
           List of labels for each directory node. If None, uses the directory node
           class names.
       colors (list, optional):
           List of colors for each directory. If None, uses default color cycle.
       markers (list, optional):
           List of markers for scatter plots. If None, uses DEFAULT_MARKERS.
       linestyles (list, optional):
           List of linestyles for line plots. If None, uses DEFAULT_LINESTYLES.
       legend (bool, optional):
           Whether to add a legend. Default is True.
       **kwargs:
           Additional keyword arguments passed to the plot method. Can include 'c' for
           color key data.

   Returns:
       matplotlib.axes.Axes:
           The axes with the plot.


.. py:function:: multi(directories, x, y=None, plot_type='scatter', figsize=None, suptitle=None, layout=None, sharex=True, sharey=True, titles=None, **kwargs)

   Create a multi-panel figure with one subplot per directory.

   Args:
       directories (list):
           List of DirectoryNode objects to plot.
       x (str):
           Key for x-axis data.
       y (str, optional):
           Key for y-axis data. Not required for histogram plots.
       plot_type (str, optional):
           Type of plot to create. Options are 'scatter', 'plot', or 'hist'.
           Default is 'scatter'.
       figsize (tuple, optional):
           Figure size (width, height) in inches.
       suptitle (str, optional):
           Super title for the entire figure.
       layout (tuple, optional):
           Layout for subplots as (rows, cols). If None, will be set automatically.
       sharex (bool, optional):
           Whether to share the x-axis across subplots. Default is True.
       sharey (bool, optional):
           Whether to share the y-axis across subplots. Default is True.
       titles (list, optional):
           List of titles for each subplot. If None, uses directory names.
       **kwargs:
           Additional keyword arguments passed to the plot method. Can include 'c' for
           color key data, 'markers' for scatter plots, 'linestyles' for line plots,
           or 'colors' for custom colors for each directory.

   Returns:
       tuple:
           (fig, axes) - The figure and array of axes created.


.. py:function:: panel(directories, *specs, figsize=None, suptitle=None, layout=None, sharex=True, sharey=True, titles=None, **kwargs)

   Create a multi-panel figure with customizable plotting specifications.

   Args:
       directories (list):
           List of DirectoryNode objects to plot.
       *specs:
           Variable number of plot specifications. Each spec is a dictionary with keys:
           - 'x': Key for x-axis data
           - 'y': Key for y-axis data (not required for histograms)
           - 'plot_type': Type of plot ('scatter', 'plot', 'hist')
           - 'c': Key for color data (optional)
           - Any other kwargs specific to that plot
       figsize (tuple, optional):
           Figure size (width, height) in inches.
       suptitle (str, optional):
           Super title for the entire figure.
       layout (tuple, optional):
           Layout for subplots as (rows, cols). If None, will be determined
           automatically.
       sharex (bool, optional):
           Whether to share the x-axis across subplots. Default is True.
       sharey (bool, optional):
           Whether to share the y-axis across subplots. Default is True.
       titles (list, optional):
           List of titles for each subplot. If None, uses descriptive titles.
       **kwargs:
           Additional keyword arguments passed to all plot methods.

   Returns:
       tuple:
           (fig, axes) - The figure and array of axes created.

   Example:
       fig, axes = ypl.panel(
           [exosims, ayo],
           {'x': 'star_dist', 'y': 'star_L', 'plot_type': 'scatter', 'c': 'star_L',
           'alpha': 0.7},
           {'x': 'wavelength', 'y': 'core_thruput', 'plot_type': 'plot', 'lw': 2},
           titles=['Star Properties', 'Throughput Curve']
       )


.. py:function:: xy_grid(directories, x_keys, y_keys, plot_type='scatter', figsize=None, suptitle=None, legend=True, sharex=False, sharey=False, titles=None, **kwargs)

   Create a grid of plots where each subplot corresponds to a set of (x, y) keys.

   Each subplot will plot all of the provided DirectoryNode objects using the
   specified plot type.

   Args:
       directories (list):
           List of DirectoryNode objects.
       x_keys (list):
           List of keys for x-axis data.
       y_keys (list):
           List of keys for y-axis data.
       plot_type (str, optional):
           Type of plot to create. Options are 'scatter', 'plot', or 'hist'.
            Default is 'scatter'.
       figsize (tuple, optional):
           Figure size in inches.
       suptitle (str, optional):
           Super title for the entire figure.
       legend (bool, optional):
           Whether to add a legend to each subplot. Default is True.
       sharex (bool, optional):
           Whether to share the x-axis across subplots. Default is True.
       sharey (bool, optional):
           Whether to share the y-axis across subplots. Default is True.
       titles (list, optional):
           List of titles for each subplot. Must have length equal to
           len(x_keys) * len(y_keys) if provided.
       **kwargs:
           Additional keyword arguments passed to the plotting method. Can
           include 'c' for color key data.

   Returns:
       tuple:
           (fig, axes) where fig is the matplotlib Figure and axes is a 2D
           array of 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()


.. py:data:: ypl_cmap

.. py:data:: ypl_colors

.. py:data:: ypl_cycler
   :value: None


.. py:data:: ypl_rainbow
   :value: None


.. py:function:: calculate_axis_limits_and_ticks(data_min, data_max, num_ticks=5, exact=False)

   Calculates the axis limits and tick spacing for a plot.

   Args:
       data_min (float):
           The minimum value of the data.
       data_max (float):
           The maximum value of the data.
       num_ticks (int, optional):
           The desired number of tick marks on the axis. Default is 5.
       exact (bool, optional):
           If True, use exact min and max values for the limits. If False, the
           limits are adjusted to "nice" values.

   Returns:
       tuple:
           nice_min (float):
               The adjusted minimum axis limit.
           nice_max (float):
               The adjusted maximum axis limit.
           tick_spacing (float):
               The spacing between ticks.
           offset (float):
               A small offset to apply to the axis limits for better visualization.


.. py:function:: get_nice_number(value, round=False)

   Calculates a "nice" number for labeling axes in a plot.

   Args:
       value (float):
           The value to be transformed into a "nice" number.
       round (bool, optional):
           If True, rounds the number to the nearest "nice" number. If False,
           the number is only scaled to be a "nice" number.

   Returns:
       float:
           A "nice" number that is a rounded or scaled version of the input value.


