arviz_plots.add_lines

Contents

arviz_plots.add_lines#

arviz_plots.add_lines(plot_collection, values, orientation='vertical', aes_by_visuals=None, visuals=None, sample_dims=None, ref_dim='ref_dim', **kwargs)[source]#

Add lines.

This function adds lines to a plot collection based on the provided values. It supports both vertical and horizontal lines, depending on the specified orientation.

Parameters:
plot_collectionPlotCollection

Plot collection to which the lines will be added.

valuesint, float, tuple, list or dict

Positions for the lines.

orientationstr, default “vertical”

The orientation of the lines, either “vertical” or “horizontal”.

aes_by_visualsmapping of {strsequence of str}, optional

Mapping of visuals to aesthetics that should use their mapping in plot_collection when plotted. Valid keys are the same as for visuals.

The default is to use an “overlay_ref” aesthetic for all elements.

It is possible to request aesthetics without mappings defined in the provided plot_collection. In those cases, a mapping of “ref_dim” to the requested aesthetic will be automatically added.

visualsmapping of {strmapping or False}, optional

Valid keys are:

  • “ref_line” -> passed to vline for vertical orientation and to hline for horizontal orientation

  • “ref_text” -> TODO

sample_dimslist, optional

Dimensions that should not be added to the Dataset generated from values via arviz_base.references_to_dataset. Defaults to all dimensions in plot_collection.data that are not facet_dims

ref_dimstr, optional

Specifies the name of the dimension for the line values. Defaults to “ref_dim”.

**kwargsmapping of {strsequence}, optional

Mapping of aesthetic keys to the values to be used in their mapping. See generate_aes_dt for more details.

Returns:
plot_collectionPlotCollection

Plot collection with the lines added.

Examples

Add lines at values 0 and 5 for all variables.

>>> from arviz_plots import plot_dist, add_lines, style
>>> style.use("arviz-variat")
>>> from arviz_base import load_arviz_data
>>> dt = load_arviz_data('centered_eight')
>>> pc = plot_dist(
>>>     dt,
>>>     kind="ecdf",
>>>     var_names=["mu"],
>>> )
>>> add_lines(pc, values=[0, 5])
../../_images/arviz_plots-add_lines-1.png