Primitives
Primitives provide the drawing API and styling helpers.
Layer 2: Drawing primitives using matplotlib.
- plotsmith.primitives.accent_point(ax, x, y, *, label=None, color=None, size=30.0, zorder=3, **kwargs)[source]
Highlight a single point with the accent color.
Optionally add a short text label offset slightly from the point.
- Parameters:
ax (
Axes) – Matplotlib axes to modify.x (
float) – X coordinate of the point.y (
float) – Y coordinate of the point.color (
str|None) – Optional color override (defaults to accent color).size (
float) – Marker size.zorder (
int) – Z-order for the marker.**kwargs – Additional arguments passed to ax.scatter().
- Return type:
- plotsmith.primitives.add_range_frame(ax, x_data=None, y_data=None)[source]
Shorten axes spines so they span only the data range.
- plotsmith.primitives.apply_axes_style(ax, spec)[source]
Apply figure specification to axes.
- Parameters:
ax (
Axes) – Matplotlib axes to style.spec (
FigureSpec) – FigureSpec containing styling information.
- Return type:
- plotsmith.primitives.direct_label(ax, x, y, text, *, dx=0.0, dy=0.0, use_accent=False, ha='left', va='center', **kwargs)[source]
Place a direct label near a data point.
Typical use is to label the last point of a line instead of using a legend.
- Parameters:
ax (
Axes) – Matplotlib axes to label.x (
float) – X coordinate of the point.y (
float) – Y coordinate of the point.text (
str) – Label text.dx (
float) – X offset for label position.dy (
float) – Y offset for label position.use_accent (
bool) – If True, use accent color.ha (
str) – Horizontal alignment.va (
str) – Vertical alignment.**kwargs – Additional arguments passed to ax.text().
- Return type:
- plotsmith.primitives.draw_band(ax, view)[source]
Draw a confidence band or shaded region on the given axes.
- plotsmith.primitives.draw_heatmap(ax, view)[source]
Draw a heatmap on the given axes.
- Parameters:
ax (
Axes) – Matplotlib axes to draw on.view (
HeatmapView) – HeatmapView containing the data to plot.
- Return type:
- plotsmith.primitives.draw_histogram(ax, view)[source]
Draw a histogram on the given axes.
- Parameters:
ax (
Axes) – Matplotlib axes to draw on.view (
HistogramView) – HistogramView containing the data to plot.
- Return type:
- plotsmith.primitives.draw_scatter(ax, view)[source]
Draw a scatter plot on the given axes.
- Parameters:
ax (
Axes) – Matplotlib axes to draw on.view (
ScatterView) – ScatterView containing the data to plot.
- Return type:
- plotsmith.primitives.draw_series(ax, view)[source]
Draw a time series on the given axes.
- Parameters:
ax (
Axes) – Matplotlib axes to draw on.view (
SeriesView) – SeriesView containing the data to plot.
- Return type:
- plotsmith.primitives.emphasize_last(ax, x, y, *, size=30.0, **kwargs)[source]
Emphasize a final point in a series using the accent color.
- plotsmith.primitives.event_line(ax, x, *, text=None, y_text=0.9, color=None, linewidth=1.0, linestyle='--', **kwargs)[source]
Draw a vertical event marker with optional label.
- Parameters:
ax (
Axes) – Matplotlib axes to modify.x (
float) – X coordinate for the vertical line.y_text (
float) – Y position for text (0-1 is fraction of y-span, otherwise data coords).color (
str|None) – Optional color override (defaults to accent color).linewidth (
float) – Line width.linestyle (
str) – Line style.**kwargs – Additional arguments passed to ax.axvline().
- Return type:
- plotsmith.primitives.force_bar_zero(ax)[source]
Force bar chart y-axis to start at zero, preserving honest scale.
- plotsmith.primitives.minimal_axes(ax)[source]
Apply minimalist axes styling.
Removes top and right spines, keeps left and bottom spines. Uses serif font.
- plotsmith.primitives.note(ax, x, y, text, **kwargs)[source]
Attach a short note with a simple arrow, avoiding legends.
- plotsmith.primitives.style_bar_plot(ax, *, horizontal=False)[source]
Style bar charts with alternating light fills and clean edges.
- plotsmith.primitives.style_line_plot(ax, *, emphasize_last=False)[source]
Apply a restrained hierarchy of line styles to an axes.