![]() |
Shamrock 2025.10.0
Astrophysical Code
|
Functions | |
| add_end_labels (ax_main, ax_annot, entries, x_pad=0.05, min_gap_px=25, fontsize=9) | |
| make_std_bench_plot (plot_data, xlabel, ylabel, title, end_label_fmt=lambda y:f"{y:.2f}", before_plot_func=None, dpi=250, figsize=(8, 6), min_gap_px=75, legend_ncol=2) | |
Helpers for building standardized benchmark plots: several series on a log-log scale, each ending in a non-overlapping value callout, with a legend row underneath. Used across Shamrock's benchmark examples.
| shamrock.utils.plot.benchmark.add_end_labels | ( | ax_main, | |
| ax_annot, | |||
| entries, | |||
| x_pad = 0.05, | |||
| min_gap_px = 25, | |||
| fontsize = 9 ) |
Place non-overlapping value callouts in a dedicated annotation axes.
`ax_annot` must share its y-axis with `ax_main` (i.e. have been created
with ``sharey=ax_main``), so a "data" y-coordinate means the same thing
in either axes. Each callout is linked back to its line's last data
point in `ax_main` with a leader line.
Parameters
----------
ax_main : matplotlib.axes.Axes
The axes holding the plotted lines.
ax_annot : matplotlib.axes.Axes
The (typically narrow, spine-less) axes the callout text is drawn
into. Must share its y-axis with `ax_main`.
entries : list of (float, float, str, color)
One ``(x, y, text, color)`` tuple per callout, where ``(x, y)`` is
the data point the leader line points to.
x_pad : float, optional
Horizontal position of the callout text, in `ax_annot` axes-fraction
coordinates.
min_gap_px : float, optional
Minimum vertical spacing between callouts, in display pixels.
fontsize : float, optional
Font size of the callout text.
Definition at line 12 of file benchmark.py.
| shamrock.utils.plot.benchmark.make_std_bench_plot | ( | plot_data, | |
| xlabel, | |||
| ylabel, | |||
| title, | |||
| end_label_fmt = lambda y: f"{y:.2f}", | |||
| before_plot_func = None, | |||
| dpi = 250, | |||
| figsize = (8, 6), | |||
| min_gap_px = 75, | |||
| legend_ncol = 2 ) |
Build a standardized benchmark plot.
Layout: a log-log plot on the left (5/6 of the width), a value-callout
panel on the right (1/6), and a legend row spanning the full width
underneath.
Parameters
----------
plot_data : dict
Maps a series key to a dict with keys ``x``, ``y``, ``color``,
``label``, ``linestyle`` and ``marker``, one entry per line to plot.
xlabel, ylabel, title : str
Axis labels and title for the main plot.
end_label_fmt : callable, optional
Formats a series' last y-value into its callout text.
before_plot_func : callable, optional
Called as ``before_plot_func(ax_main)`` before the series in
`plot_data` are plotted, e.g. to draw reference lines underneath
them.
dpi, figsize : optional
Passed to `matplotlib.pyplot.figure`.
min_gap_px : float, optional
Minimum vertical spacing between callouts, in display pixels; see
`add_end_labels`.
legend_ncol : int, optional
Number of columns in the legend row.
Returns
-------
(matplotlib.figure.Figure, matplotlib.axes.Axes)
The created figure and its main (plot) axes.
Definition at line 104 of file benchmark.py.