AZPlotGrid
A grid container for multiple AZPlottingClass subplots. Provides
linked axis support (synchronized zoom/pan across plots) and bulk operations.
#include "AZPlotGrid.h"
class AZPlotGrid : public QWidget
Quick Example
// Create a 2x2 grid of plots
AZPlotGrid *grid = new AZPlotGrid(2, 2, parent);
// Access individual plots by row/col
grid->plot(0, 0)->addDataSeries(x1, y1, "Top-left");
grid->plot(0, 1)->addDataSeries(x2, y2, "Top-right");
grid->plot(1, 0)->addDataSeries(x3, y3, "Bottom-left");
grid->plot(1, 1)->addDataSeries(x4, y4, "Bottom-right");
// Link X-axes: zoom/pan one plot affects all
grid->linkXAxes(true);
// Apply theme to all plots at once
grid->applyProfessionalStyle();
Constructor
Creates an mxn grid of AZPlottingClass widgets.
| Parameter | Type | Description |
|---|---|---|
| rows | int | Number of rows in the grid |
| cols | int | Number of columns in the grid |
| parent | QWidget* | Parent widget for ownership |
Access Methods
plot (by row/col)
Returns the plot at the specified row and column (0-indexed). Returns nullptr if out of bounds.
plot (by index)
Returns the plot at a linear index (row-major order). Useful for iteration.
rowCount / colCount / plotCount
Returns grid dimensions and total number of plots.
Axis Linking
When axes are linked, zooming or panning on one subplot automatically applies the same transformation to all other subplots. This is essential for comparing related datasets across multiple views.
linkXAxes
Links X-axes across all subplots. When linked, horizontal zoom/pan on any plot affects all plots.
linkYAxes
Links Y-axes across all subplots. When linked, vertical zoom/pan on any plot affects all plots.
linkAllAxes
Links both X and Y axes across all subplots.
xAxesLinked / yAxesLinked
Query whether axes are currently linked.
Bulk Operations
Apply settings to all subplots at once:
applyProfessionalStyle / applyDarkTheme
Applies the theme to all subplots.
setAllInteractive
Enables or disables zoom and pan on all subplots.
setAllGridVisible
Sets grid visibility on all subplots.
Layout
setSpacing
Sets the spacing between subplots in pixels.
setMargins
Sets the outer margins of the grid container.
Export
exportToPNG
Exports the entire grid as a single PNG image. Each subplot is rendered at
(width/cols) x (height/rows) size.
exportToPDF
Exports the grid to PDF format.
State Persistence
saveState / loadState
Serializes/deserializes the entire grid state including all subplot states, axis linking settings, and layout configuration.
saveStateToFile / loadStateFromFile
File-based convenience methods for state persistence.
Signals
Emitted when any subplot's visible range changes. Useful for synchronizing external UI elements.