publiplots.add_reference_line¶
- publiplots.add_reference_line(ax, value, axis='y', color='red', linestyle='--', linewidth=1.5, alpha=0.7, label=None, zorder=1)[source]¶
Add a reference line to the plot.
Useful for showing thresholds, means, or other reference values. Internally calls
axhline()(foraxis='y') oraxvline()(foraxis='x').- Parameters:
ax (matplotlib.axes.Axes) – Axes to modify in place.
value (float) – Position of the reference line in data coordinates.
axis ({‘x’, ‘y’}, default
'y') – Which axis to add the line to:'x'draws a vertical line atx=value;'y'draws a horizontal line aty=value.color (str, default
'red') – Line color.linestyle (str, default
'--') – Matplotlib linestyle spec.linewidth (float, default
1.5) – Line width (points).alpha (float, default
0.7) – Line transparency in[0, 1].label (str, optional) – Label for the legend.
Noneleaves the line unlabelled.zorder (int, default
1) – Line z-order (higher values render on top).
- Raises:
ValueError – If
axisis not'x'or'y'.
Examples
Add horizontal reference line at
y=0:>>> pp.add_reference_line(ax, value=0, axis='y', label='Baseline')Add vertical line at
x=5:>>> pp.add_reference_line(ax, value=5, axis='x', color='steelblue')