Interval Curve - QwtPlotIntervalCurve¶
QwtPlotIntervalCurve is used to draw interval curves with upper and lower bounds, commonly used to display error ranges, confidence intervals, fluctuation ranges, and similar data. Each data point contains a position value and an interval range.
Key Features¶
- Interval representation: Displays upper and lower bounds around the curve
- Multiple styles: Supports curve, filled area, symbol, and other display modes
- Error bar display: Can draw vertical or horizontal error bar lines
- Style customization: Interval boundaries and fill can be configured independently
Basic Concepts¶
Interval Curve Composition¶
The diagram below shows a Tube interval curve: the upper and lower interval bounds form two boundary curves, and the area between them is filled:
1 2 3 4 5 6 7 8 9 | |
Data Structure¶
Uses QwtIntervalSample to represent interval data, where a position value on one axis is paired with an interval on the other:
1 2 3 4 5 6 7 8 9 | |
Curve Styles¶
| Style | Enum Value | Description |
|---|---|---|
| No curve | NoCurve |
Don't draw a curve; symbols (e.g. error bars) are still displayed |
| Tube | Tube |
Draw the upper/lower bounds as two curves with pen() and fill the area between them with brush() |
| User curve | UserCurve |
Reserved for derived classes that overload drawSeries() |
Usage¶
1. Basic Interval Curve¶
QwtPlotIntervalCurve consumes QwtIntervalSample data, where each sample pairs a median value with a QwtInterval range, and its CurveStyle (NoCurve / Tube, default Tube) decides how the intervals are rendered. In Tube style setPen() strokes the boundary curves while setBrush() fills the area between them. The example below creates a plot and draws four samples as a translucent band:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | |
2. Error Bar Style¶
CurveStyle has no dedicated error-bar value; error bars are produced by switching the curve style to NoCurve and attaching a QwtIntervalSymbol via setSymbol(): the symbol's Style picks the cap shape (Bar draws a line with end caps), the symbol's own setPen() determines the stroke and setWidth() the cap size. setSymbol() takes ownership of the pointer. The snippet below draws error bars only:
1 2 3 4 5 6 7 8 9 10 | |
3. Tube Style Configuration¶
In Tube style the upper and lower bounds are stroked with the item's setPen() and the area between them is filled through setBrush() (default Qt::NoBrush, i.e. unfilled). The snippet below configures a red stroke with a translucent pink fill for the tube:
1 2 3 4 5 6 7 | |
4. Symbol Configuration¶
QwtIntervalSymbol is constructed with a Style, either Bar for a line with end caps or Box for a plain rectangle, and is tuned via setPen(), setBrush(), and setWidth() (stroke/cap width in pixels) before being assigned to the curve with setSymbol(), which takes ownership of the pointer. The example below creates a blue Bar symbol 8 pixels wide:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
Core Methods Summary¶
| Method | Description |
|---|---|
setSamples() |
Set interval data (QVector<QwtIntervalSample> or QwtSeriesData<QwtIntervalSample>*) |
setStyle() |
Set curve style (NoCurve / Tube) |
setPen() |
Set the pen stroking the boundary curves (Tube style) |
setBrush() |
Set the brush filling the tube area |
setSymbol() |
Set the interval symbol drawn per sample (ownership transferred) |
setPaintAttribute() |
Toggle clipping hints (ClipPolygons / ClipSymbol) |
Tip — Application Scenarios
- Experimental data error display
- Confidence interval visualization
- Fluctuation range display
- Prediction interval display
Example — Related Examples
- Interval curve demo: See custom examples