yieldplotlib#

yieldplotlib - A library for plotting yield data.

Submodules#

Attributes#

Functions#

fetch_ayo_data()

Fetch and unpack AYO data.

fetch_exosims_data()

Fetch and unpack EXOSIMS data.

fetch_yip_data()

Fetch and unpack YIP data.

compare(ax, directories, x[, y, plot_type, labels, ...])

Plot data from multiple directories on a single axes.

multi(directories, x[, y, plot_type, figsize, ...])

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

panel(directories, *specs[, figsize, suptitle, ...])

Create a multi-panel figure with customizable plotting specifications.

xy_grid(directories, x_keys, y_keys[, plot_type, ...])

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

subplots(*args, **kwargs)

A simple wrapper around plt.subplots().

calculate_axis_limits_and_ticks(data_min, data_max[, ...])

Calculates the axis limits and tick spacing for a plot.

get_nice_number(value[, round])

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

Package Contents#

yieldplotlib.fetch_ayo_data()[source]#

Fetch and unpack AYO data.

yieldplotlib.fetch_exosims_data()[source]#

Fetch and unpack EXOSIMS data.

yieldplotlib.fetch_yip_data()[source]#

Fetch and unpack YIP data.

yieldplotlib.KEY_MAP#
yieldplotlib.logger#
yieldplotlib.compare(ax, directories, x, y=None, plot_type='scatter', labels=None, colors=None, markers=None, linestyles=None, legend=True, **kwargs)[source]#

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.

yieldplotlib.multi(directories, x, y=None, plot_type='scatter', figsize=None, suptitle=None, layout=None, sharex=True, sharey=True, titles=None, **kwargs)[source]#

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.

yieldplotlib.panel(directories, *specs, figsize=None, suptitle=None, layout=None, sharex=True, sharey=True, titles=None, **kwargs)[source]#

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

)

yieldplotlib.xy_grid(directories, x_keys, y_keys, plot_type='scatter', figsize=None, suptitle=None, legend=True, sharex=False, sharey=False, titles=None, **kwargs)[source]#

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.

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

yieldplotlib.ypl_cmap#
yieldplotlib.ypl_colors#
yieldplotlib.ypl_cycler = None#
yieldplotlib.ypl_rainbow = None#
yieldplotlib.calculate_axis_limits_and_ticks(data_min, data_max, num_ticks=5, exact=False)[source]#

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.

yieldplotlib.get_nice_number(value, round=False)[source]#

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.