Skip to content

Commit dfa786c

Browse files
committed
docs: add quick references for composition, DataTable, and versioned themes
1 parent 2d8ca92 commit dfa786c

4 files changed

Lines changed: 48 additions & 0 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ Pure C++20 plotting API with a gnuplot renderer for figures.
2525
- Data transforms (`moving_average`, `downsample_uniform`, `autocorrelation`)
2626
- CSV ingestion and unit-aware labels (`read_csv_numeric`, `label_with_unit`)
2727
- Faceting helpers (`facet_grid`, `apply_facet_axes`)
28+
- Composition helpers (`apply_panel_titles`, `apply_shared_legend`, `apply_shared_colorbar_label`)
29+
- Auto legend placement heuristic (`auto_place_legend`)
2830
- YAML declarative spec loading (`load_yaml_figure_spec`)
2931
- Template gallery and quick templates (`apply_plot_template`, `write_template_gallery_yaml`)
32+
- DataTable column plotting adapters (`add_line`, `add_scatter`)
33+
- Versioned theme presets (`ThemePreset::*_v1`)
3034
- Font fallback chain for cross-format typography consistency
3135
- Reproducibility manifest export (`manifest.json`)
3236

docs/EXAMPLES.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This file maps repository examples to practical use-cases.
1313

1414
- `feature_rich_showcase.cpp`: confidence bands, histogram+KDE, heatmap, y2 axis.
1515
- `interactive_facet_example.cpp`: facet grid + interactive preview script.
16+
- `interactive_facet_example.cpp`: facet grid + shared legend + auto legend placement + DataTable column plotting.
1617
- `yaml_spec_example.cpp`: declarative plotting from YAML.
1718
- `stats_plot_examples.cpp`: Q-Q, violin, box summary, confidence ellipses, autocorrelation.
1819
- `monte_carlo_alpha_example.cpp`: dense ensemble rendering + 3-sigma envelope.
@@ -44,3 +45,24 @@ When creating a new example, copy one close to your use-case:
4445
1. Keep `FigureSpec` + profile setup.
4546
2. Replace data generation with your source.
4647
3. Keep `fig.save(out_dir / "figures")` convention.
48+
49+
## New Composition + DataTable Pattern
50+
51+
```cpp
52+
auto tbl = gnuplotpp::read_csv_numeric("demo.csv");
53+
gnuplotpp::apply_facet_axes(fig, base, {"A", "B", "C", "D"});
54+
gnuplotpp::apply_panel_titles(fig, {"A", "B", "C", "D"});
55+
56+
for (int k = 0; k < 4; ++k) {
57+
const auto& y = tbl.column(cols_name[k]);
58+
auto ax_spec = fig.axes(k).spec();
59+
gnuplotpp::auto_place_legend(ax_spec, tbl.column("t"), y);
60+
fig.axes(k).set(ax_spec);
61+
tbl.add_line(fig.axes(k), {.label = "mean"}, "t", cols_name[k]);
62+
}
63+
64+
gnuplotpp::LegendSpec shared_legend;
65+
shared_legend.enabled = true;
66+
shared_legend.position = gnuplotpp::LegendPosition::TopLeft;
67+
gnuplotpp::apply_shared_legend(fig, shared_legend, 0);
68+
```

docs/PLOT_CONTROLS.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ This document is the full control reference for `gnuplotpp` plotting.
1515
- `gnuplotpp::save_theme_json` / `gnuplotpp::load_theme_json`
1616
- `gnuplotpp::read_csv_numeric`
1717
- `gnuplotpp::facet_grid` / `gnuplotpp::apply_facet_axes`
18+
- `gnuplotpp::apply_panel_titles` / `gnuplotpp::apply_shared_legend` / `gnuplotpp::apply_shared_colorbar_label`
19+
- `gnuplotpp::auto_legend_position` / `gnuplotpp::auto_place_legend`
1820
- `gnuplotpp::load_yaml_figure_spec`
1921
- `gnuplotpp::apply_plot_template`
2022

@@ -206,6 +208,9 @@ gnuplotpp::confidence_ellipse(x, y, 2.0, ell_x, ell_y, 200);
206208
207209
```cpp
208210
auto tbl = gnuplotpp::read_csv_numeric("signals.csv");
211+
if (tbl.has_column("time") && tbl.has_column("error")) {
212+
tbl.add_line(fig.axes(0), {.label = "error"}, "time", "error");
213+
}
209214
auto [rows, cols] = gnuplotpp::facet_grid(6);
210215
fs.rows = rows;
211216
fs.cols = cols;
@@ -214,6 +219,14 @@ gnuplotpp::AxesSpec base;
214219
base.xlabel = gnuplotpp::label_with_unit("time", "s");
215220
base.ylabel = gnuplotpp::label_with_unit("error", "m");
216221
gnuplotpp::apply_facet_axes(fig, base, {"A","B","C","D","E","F"});
222+
223+
// Composition helpers
224+
gnuplotpp::apply_panel_titles(fig, {"(a)", "(b)", "(c)", "(d)", "(e)", "(f)"});
225+
gnuplotpp::LegendSpec shared_legend;
226+
shared_legend.enabled = true;
227+
shared_legend.position = gnuplotpp::LegendPosition::TopLeft;
228+
gnuplotpp::apply_shared_legend(fig, shared_legend, 0);
229+
gnuplotpp::apply_shared_colorbar_label(fig, "density", rows * cols - 1);
217230
```
218231

219232
### YAML Figure Spec

docs/STYLING_AND_PRESETS.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ gnuplotpp::apply_style_profile(fs, gnuplotpp::StyleProfile::Tufte_Minimal);
2525
- `DarkPrintSafe`
2626
- `Tufte_Minimal`
2727
28+
## Versioned Theme Presets
29+
30+
For reproducibility across releases, use versioned theme ids:
31+
32+
```cpp
33+
gnuplotpp::apply_theme_preset(fs, gnuplotpp::ThemePreset::IEEE_Strict_v1);
34+
auto id = gnuplotpp::theme_preset_id(gnuplotpp::ThemePreset::IEEE_Strict_v1);
35+
```
36+
2837
## Typography Model
2938

3039
Typography is preset/profile-driven by default:

0 commit comments

Comments
 (0)