A lightweight matplotlib style library for producing publication-ready benchmark plots with consistent styling, colorblind-safe palettes, and zero configuration.
pip install git+https://github.com/NASA-IMPACT/plotperfect.gitFor local development:
pip install -e ./plotperfectGrouped Bar![]() |
Single Bar![]() |
Line Plot![]() |
Scatter Plot![]() |
Stacked Bar![]() |
Horizontal Bar![]() |
import plotperfect as S
S.apply_style()
fig, ax = S.new_figure()
ax.bar(["A", "B", "C"], [3, 7, 5], color=S.COLOR_PRIMARY)
S.style_ax(ax, title="Demo", xlabel="Category", ylabel="Value")
S.save(fig, "demo.png")See example.py for complete examples of every plot type shown in the gallery.
Ten colorblind-safe colors based on the seaborn "colorblind" palette. Access individual colors via S.COLORS["blue"] or use S.PALETTE (an ordered list) for multi-series plots.
Semantic aliases:
| Alias | Color | Hex |
|---|---|---|
COLOR_PRIMARY |
blue | #2A79DB |
COLOR_SECONDARY |
grey | #949494 |
COLOR_TERTIARY |
green | #029E73 |
All text is rendered in DM Sans (bundled with the package, auto-registered at import).
| Element | Size | Weight |
|---|---|---|
| Title | 14 pt | Bold |
| Axis labels | 14 pt | Bold |
| Tick labels | 12 pt | Regular |
| Legend | 14 pt | Regular |
| Annotations | 11 pt | Regular |
| Property | Default |
|---|---|
| Figure size | 10 x 7 in |
| DPI | 300 |
| Bar width | 0.35 |
| Bar edge width | 1.5 |
Every plot should be distinguishable without color:
- Bar plots — apply
S.HATCHES(white hatch patterns) to differentiate series - Line / Scatter plots — apply
S.MARKERS(distinct shapes per series)
style_ax() enforces a clean, consistent look:
- Bold title and axis labels
- Horizontal grid lines behind data
- No vertical grid
- Top and right spines removed
- Bottom and left spines in
#333333
add_legend() places the legend below the chart (bottom-center, outside the axes) in a single row with no title.
| Function | Default format | Notes |
|---|---|---|
annotate_bars() |
{val:.2f} |
Pass total=N for percentage format |
annotate_line() |
{val:.2f} |
Configurable offset and format |
Both accept a custom fmt string with {val}, {pct}, and {total} placeholders.
| Function | Description |
|---|---|
apply_style() |
Set global matplotlib rcParams. Call once per script. |
new_figure() |
Return a styled (fig, ax) pair. |
style_ax() |
Apply grid, spines, labels, and limits to an axes. |
annotate_bars() |
Add value labels above each bar. |
annotate_line() |
Add value labels at each data point on a line. |
add_legend() |
Place a bottom-center legend outside the axes. |
save() |
Save the figure at 300 DPI with tight bounding box. |






