AZPlottingClass
The main plotting widget class. Inherits from QWidget and wraps
QCustomPlot with a simplified API for scientific data visualization.
#include "AZPlottingClass.h"
class AZPlottingClass : public QWidget
Constructor
Creates a new plotting widget. Pass a parent widget for automatic memory management,
or nullptr for a standalone window.
Data Methods
addDataSeries
Adds a line series to the primary Y-axis. Returns a series ID for later reference.
| Parameter | Type | Description |
|---|---|---|
| x | QVector<double> | X-axis data values |
| y | QVector<double> | Y-axis data values (must match x size) |
| name | QString | Legend label (empty to hide from legend) |
| color | QColor | Line color |
| style | LineStyle | Solid, Dashed, Dotted, DashDot, or None |
| lineWidth | double | Line width in pixels |
int - Series ID for use with appendData(), removeSeries(), etc.
std::vector,
std::initializer_list, raw pointers, and Y-only (auto-generates X as 0, 1, 2...).
addDataSeriesToY2
Adds a line series to the secondary Y-axis (right side). Automatically enables and shows the Y2 axis. Useful for Bode plots or comparing data with different units.
addScatterSeries
Adds a scatter plot (markers only, no connecting lines).
| Parameter | Type | Description |
|---|---|---|
| marker | MarkerStyle | Circle, Square, Diamond, Triangle, Cross, Plus, or Star |
| markerSize | double | Marker diameter in pixels |
addLineMarkerSeries
Adds a series with both connecting lines and markers at each data point.
addBarSeries
Adds a bar chart. The width parameter controls bar width relative to spacing.
appendData
Appends data points to an existing series without clearing. Designed for real-time
data streaming. Use with replotQueued() for efficient high-frequency updates.
clearData / removeSeries
clearData() removes all series. removeSeries(id) removes a specific series by ID.
setScrollingWindow
Enables auto-scrolling for real-time plots. The X-axis will automatically pan to show
the last windowWidth units of data. Call clearScrollingWindow(seriesId) to disable.
Axis Methods
setXAxisScale / setYAxisScale / setY2AxisScale
Sets the axis scale type:
ScaleType::Linear- Standard linear scaleScaleType::Logarithmic- Base-10 logarithmic (positive values only)ScaleType::SymLog- Symmetric logarithmic (handles negative values)
setXAxisRange / setYAxisRange / setY2AxisRange
Manually sets the visible range for an axis.
autoScaleX / autoScaleY / autoScaleAll
Automatically fits axis ranges to encompass all visible data with a small margin.
setXAxisLabel / setYAxisLabel / setY2AxisLabel / setTitle
Sets axis labels and plot title. Supports UTF-8 for units (e.g., "dB/dt (nV/m²)").
setXAxisInverted / setYAxisInverted
Inverts an axis (useful for depth plots where depth increases downward).
setLinearThreshold / setLinearWidth
Configures the SymLog transform. linearThreshold defines the range around zero
that uses linear scaling. linearWidth controls how much visual space that linear
region occupies.
Appearance Methods
applyProfessionalStyle / applyDarkTheme
Applies preset themes. applyProfessionalStyle() sets preset fonts and colors
with subtle colors. applyDarkTheme() switches to a dark background suitable for
extended viewing.
setGridVisible
Shows or hides major and minor grid lines.
setLegendVisible / setLegendPosition
Controls legend visibility and position (e.g., Qt::AlignTop | Qt::AlignRight).
setCrosshairEnabled
Enables a crosshair cursor that follows the mouse with coordinate readout.
setStatsVisible / setStatsPosition
Shows an overlay with data statistics (min, max, mean) for all visible series.
Annotation Methods
addVerticalLine / addHorizontalLine
Adds marker lines that span the entire plot area. Useful for threshold indicators.
addTextAnnotation
Adds a text label at plot coordinates. Returns an annotation ID.
addArrowAnnotation
Adds an arrow from (x1, y1) to (x2, y2). Set doubleEnded for bidirectional arrows.
addRectAnnotation / addEllipseAnnotation
Adds shape annotations with configurable border and fill colors.
addLabeledEllipse / addLabeledRect
Convenience methods that combine a shape with a centered text label.
Export Methods
exportToPNG / exportToPDF
Exports the plot to an image file. The scale parameter for PNG creates a higher-resolution
image (2.0 = retina/HiDPI). Returns true on success.
copyToClipboard
Copies the current plot image to the system clipboard.
saveState / loadState
Serializes/deserializes the complete plot state (data, ranges, styles, annotations) to JSON. Useful for session persistence.
saveStateToFile / loadStateFromFile
Convenience methods that save/load state directly to/from a JSON file.
Interaction Methods
setInteractive
Enables or disables mouse zoom and pan interactions.
resetZoom / zoomBack
resetZoom() restores the original view. zoomBack() pops the last zoom state
from history (also triggered by right-click).
plot()
Returns the underlying QCustomPlot instance for advanced customization beyond
this wrapper's API.