![]() |
.Simulation
|
A plottable representing a single statistical box in a plot. More...
Public Member Functions | |
QCPStatisticalBox (QCPAxis *keyAxis, QCPAxis *valueAxis) | |
Constructs a statistical box which uses keyAxis as its key axis ("x") and valueAxis as its value axis ("y"). More... | |
double | key () const |
double | minimum () const |
double | lowerQuartile () const |
double | median () const |
double | upperQuartile () const |
double | maximum () const |
QVector< double > | outliers () const |
double | width () const |
double | whiskerWidth () const |
QPen | whiskerPen () const |
QPen | whiskerBarPen () const |
QPen | medianPen () const |
double | outlierSize () const |
QPen | outlierPen () const |
QCP::ScatterStyle | outlierStyle () const |
void | setKey (double key) |
Sets the key coordinate of the statistical box. | |
void | setMinimum (double value) |
Sets the parameter "minimum" of the statistical box plot. More... | |
void | setLowerQuartile (double value) |
Sets the parameter "lower Quartile" of the statistical box plot. More... | |
void | setMedian (double value) |
Sets the parameter "median" of the statistical box plot. More... | |
void | setUpperQuartile (double value) |
Sets the parameter "upper Quartile" of the statistical box plot. More... | |
void | setMaximum (double value) |
Sets the parameter "maximum" of the statistical box plot. More... | |
void | setOutliers (const QVector< double > &values) |
Sets a vector of outlier values that will be drawn as circles. More... | |
void | setData (double key, double minimum, double lowerQuartile, double median, double upperQuartile, double maximum) |
Sets all parameters of the statistical box plot at once. More... | |
void | setWidth (double width) |
Sets the width of the box in key coordinates. More... | |
void | setWhiskerWidth (double width) |
Sets the width of the whiskers (setMinimum, setMaximum) in key coordinates. More... | |
void | setWhiskerPen (const QPen &pen) |
Sets the pen used for drawing the whisker backbone (That's the line parallel to the value axis). More... | |
void | setWhiskerBarPen (const QPen &pen) |
Sets the pen used for drawing the whisker bars (Those are the lines parallel to the key axis at each end of the backbone). More... | |
void | setMedianPen (const QPen &pen) |
Sets the pen used for drawing the median indicator line inside the statistical box. More... | |
void | setOutlierSize (double pixels) |
Sets the pixel size of the scatter symbols that represent the outlier data points. More... | |
void | setOutlierPen (const QPen &pen) |
Sets the pen used to draw the outlier data points. More... | |
void | setOutlierStyle (QCP::ScatterStyle style) |
Sets the scatter style of the outlier data points. More... | |
virtual void | clearData () |
Clears all data in the plottable. | |
virtual double | selectTest (const QPointF &pos) const |
This function is used to decide whether a click hits a plottable or not. More... | |
![]() | |
QCPAbstractPlottable (QCPAxis *keyAxis, QCPAxis *valueAxis) | |
Constructs an abstract plottable which uses keyAxis as its key axis ("x") and valueAxis as its value axis ("y"). More... | |
QString | name () const |
bool | antialiasedFill () const |
bool | antialiasedScatters () const |
bool | antialiasedErrorBars () const |
QPen | pen () const |
QPen | selectedPen () const |
QBrush | brush () const |
QBrush | selectedBrush () const |
QCPAxis * | keyAxis () const |
QCPAxis * | valueAxis () const |
bool | selectable () const |
bool | selected () const |
void | setName (const QString &name) |
The name is the textual representation of this plottable as it is displayed in the QCPLegend of the parent QCustomPlot. More... | |
void | setAntialiasedFill (bool enabled) |
Sets whether fills of this plottable is drawn antialiased or not. More... | |
void | setAntialiasedScatters (bool enabled) |
Sets whether the scatter symbols of this plottable are drawn antialiased or not. More... | |
void | setAntialiasedErrorBars (bool enabled) |
Sets whether the error bars of this plottable are drawn antialiased or not. More... | |
void | setPen (const QPen &pen) |
The pen is used to draw basic lines that make up the plottable representation in the plot. More... | |
void | setSelectedPen (const QPen &pen) |
When the plottable is selected, this pen is used to draw basic lines instead of the normal pen set via setPen. More... | |
void | setBrush (const QBrush &brush) |
The brush is used to draw basic fills of the plottable representation in the plot. More... | |
void | setSelectedBrush (const QBrush &brush) |
When the plottable is selected, this brush is used to draw fills instead of the normal brush set via setBrush. More... | |
void | setKeyAxis (QCPAxis *axis) |
The key axis of a plottable can be set to any axis of a QCustomPlot, as long as it is orthogonal to the plottable's value axis. More... | |
void | setValueAxis (QCPAxis *axis) |
The value axis of a plottable can be set to any axis of a QCustomPlot, as long as it is orthogonal to the plottable's key axis. More... | |
void | setSelectable (bool selectable) |
Sets whether the user can (de-)select this plottable by clicking on the QCustomPlot surface. More... | |
void | setSelected (bool selected) |
Sets whether this plottable is selected or not. More... | |
void | rescaleAxes (bool onlyEnlarge=false) const |
Rescales the key and value axes associated with this plottable to contain all displayed data, so the whole plottable is visible. More... | |
void | rescaleKeyAxis (bool onlyEnlarge=false) const |
Rescales the key axis of the plottable so the whole plottable is visible. More... | |
void | rescaleValueAxis (bool onlyEnlarge=false) const |
Rescales the value axis of the plottable so the whole plottable is visible. More... | |
virtual bool | addToLegend () |
Adds this plottable to the legend of the parent QCustomPlot. More... | |
virtual bool | removeFromLegend () const |
Removes the plottable from the legend of the parent QCustomPlot. More... | |
![]() | |
QCPLayerable (QCustomPlot *parentPlot) | |
Creates a new QCPLayerable instance. More... | |
bool | visible () const |
QCustomPlot * | parentPlot () const |
QCPLayer * | layer () const |
bool | antialiased () const |
void | setVisible (bool on) |
Sets the visibility of this layerable object. More... | |
bool | setLayer (QCPLayer *layer) |
Sets the layer of this layerable object. More... | |
bool | setLayer (const QString &layerName) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Sets the layer of this layerable object by name. More... | |
void | setAntialiased (bool enabled) |
Sets whether this object will be drawn antialiased or not. More... | |
Protected Member Functions | |
virtual void | draw (QCPPainter *painter) |
virtual void | drawLegendIcon (QCPPainter *painter, const QRect &rect) const |
virtual void | drawQuartileBox (QCPPainter *painter, QRectF *quartileBox=0) const |
virtual void | drawMedian (QCPPainter *painter) const |
virtual void | drawWhiskers (QCPPainter *painter) const |
virtual void | drawOutliers (QCPPainter *painter) const |
virtual QCPRange | getKeyRange (bool &validRange, SignDomain inSignDomain=sdBoth) const |
virtual QCPRange | getValueRange (bool &validRange, SignDomain inSignDomain=sdBoth) const |
![]() | |
virtual QRect | clipRect () const |
void | coordsToPixels (double key, double value, double &x, double &y) const |
const QPointF | coordsToPixels (double key, double value) const |
void | pixelsToCoords (double x, double y, double &key, double &value) const |
void | pixelsToCoords (const QPointF &pixelPos, double &key, double &value) const |
QPen | mainPen () const |
QBrush | mainBrush () const |
void | applyDefaultAntialiasingHint (QCPPainter *painter) const |
void | applyFillAntialiasingHint (QCPPainter *painter) const |
void | applyScattersAntialiasingHint (QCPPainter *painter) const |
void | applyErrorBarsAntialiasingHint (QCPPainter *painter) const |
double | distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const |
![]() | |
bool | moveToLayer (QCPLayer *layer, bool prepend) |
void | applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const |
Protected Attributes | |
QVector< double > | mOutliers |
double | mKey |
double | mMinimum |
double | mLowerQuartile |
double | mMedian |
double | mUpperQuartile |
double | mMaximum |
double | mWidth |
double | mWhiskerWidth |
double | mOutlierSize |
QPen | mWhiskerPen |
QPen | mWhiskerBarPen |
QPen | mOutlierPen |
QPen | mMedianPen |
QCP::ScatterStyle | mOutlierStyle |
![]() | |
QString | mName |
bool | mAntialiasedFill |
bool | mAntialiasedScatters |
bool | mAntialiasedErrorBars |
QPen | mPen |
QPen | mSelectedPen |
QBrush | mBrush |
QBrush | mSelectedBrush |
QCPAxis * | mKeyAxis |
QCPAxis * | mValueAxis |
bool | mSelected |
bool | mSelectable |
![]() | |
bool | mVisible |
QCustomPlot * | mParentPlot |
QCPLayer * | mLayer |
bool | mAntialiased |
Friends | |
class | QCustomPlot |
class | QCPLegend |
Additional Inherited Members | |
![]() | |
void | selectionChanged (bool selected) |
This signal is emitted when the selection state of this plottable has changed, either by user interaction or by a direct call to setSelected. | |
![]() | |
enum | SignDomain { sdNegative, sdBoth, sdPositive } |
Represents negative and positive sign domain for passing to getKeyRange and getValueRange. More... | |
A plottable representing a single statistical box in a plot.
To plot data, assign it with the individual parameter functions or use setData to set all parameters at once. The individual funcions are:
Additionally you can define a list of outliers, drawn as circle datapoints:
The appearance of the box itself is controlled via setPen and setBrush. You may change the width of the box with setWidth in plot coordinates (not pixels).
Analog functions exist for the minimum/maximum-whiskers: setWhiskerPen, setWhiskerBarPen, setWhiskerWidth. The whisker width is the width of the bar at the top (maximum) or bottom (minimum).
The median indicator line has its own pen, setMedianPen.
If the pens are changed, especially the whisker pen, make sure to set the capStyle to Qt::FlatCap. Else, e.g. the whisker line might exceed the bar line by a few pixels due to the pen cap being not perfectly flat.
The Outlier data points are drawn normal scatter points. Their look can be controlled with setOutlierStyle and setOutlierPen. The size (diameter) can be set with setOutlierSize in pixels.
Like all data representing objects in QCustomPlot, the QCPStatisticalBox is a plottable (QCPAbstractPlottable). So the plottable-interface of QCustomPlot applies (QCustomPlot::plottable, QCustomPlot::addPlottable, QCustomPlot::removePlottable, etc.)
Usually, you first create an instance:
add it to the customPlot with QCustomPlot::addPlottable:
and then modify the properties of the newly created plottable, e.g.:
Constructs a statistical box which uses keyAxis as its key axis ("x") and valueAxis as its value axis ("y").
keyAxis and valueAxis must reside in the same QCustomPlot instance and not have the same orientation. If either of these restrictions is violated, a corresponding message is printed to the debug output (qDebug), the construction is not aborted, though.
The constructed statistical box can be added to the plot with QCustomPlot::addPlottable, QCustomPlot then takes ownership of the statistical box.
|
virtual |
This function is used to decide whether a click hits a plottable or not.
pos is a point in pixel coordinates on the QCustomPlot surface. This function returns the shortest pixel distance of this point to the plottable (e.g. to the scatters/lines of a graph). If the plottable is either invisible, contains no data or the distance couldn't be determined, -1.0 is returned. setSelectable has no influence on the return value of this function.
If the plottable is represented not by single lines but by an area like QCPBars or QCPStatisticalBox, a click inside the area returns a constant value greater zero (typically 99% of the selectionTolerance of the parent QCustomPlot). If the click lies outside the area, this function returns -1.0.
Providing a constant value for area objects allows selecting line objects even when they are obscured by such area objects, by clicking close to the lines (i.e. closer than 0.99*selectionTolerance).
The actual setting of the selection state is not done by this function. This is handled by the parent QCustomPlot when the mouseReleaseEvent occurs.
Implements QCPlot::QCPAbstractPlottable.
void QCPlot::QCPStatisticalBox::setData | ( | double | key, |
double | minimum, | ||
double | lowerQuartile, | ||
double | median, | ||
double | upperQuartile, | ||
double | maximum | ||
) |
Sets all parameters of the statistical box plot at once.
void QCPlot::QCPStatisticalBox::setLowerQuartile | ( | double | value | ) |
Sets the parameter "lower Quartile" of the statistical box plot.
This is the lower end of the box. The lower and the upper quartiles are the two statistical quartiles around the median of the sample, they contain 50% of the sample data.
void QCPlot::QCPStatisticalBox::setMaximum | ( | double | value | ) |
Sets the parameter "maximum" of the statistical box plot.
This is the position of the upper whisker, typically the maximum measurement of the sample that's not considered an outlier.
void QCPlot::QCPStatisticalBox::setMedian | ( | double | value | ) |
Sets the parameter "median" of the statistical box plot.
This is the value of the median mark inside the quartile box. The median separates the sample data in half (50% of the sample data is below/above the median).
void QCPlot::QCPStatisticalBox::setMedianPen | ( | const QPen & | pen | ) |
Sets the pen used for drawing the median indicator line inside the statistical box.
Make sure to set the pen capStyle to Qt::FlatCap to prevent the median line from reaching a few pixels outside the box, when using a non-zero pen width.
void QCPlot::QCPStatisticalBox::setMinimum | ( | double | value | ) |
Sets the parameter "minimum" of the statistical box plot.
This is the position of the lower whisker, typically the minimum measurement of the sample that's not considered an outlier.
void QCPlot::QCPStatisticalBox::setOutlierPen | ( | const QPen & | pen | ) |
Sets the pen used to draw the outlier data points.
void QCPlot::QCPStatisticalBox::setOutliers | ( | const QVector< double > & | values | ) |
Sets a vector of outlier values that will be drawn as circles.
Any data points in the sample that are not within the whiskers (setMinimum, setMaximum) should be considered outliers and displayed as such.
void QCPlot::QCPStatisticalBox::setOutlierSize | ( | double | pixels | ) |
Sets the pixel size of the scatter symbols that represent the outlier data points.
void QCPlot::QCPStatisticalBox::setOutlierStyle | ( | QCP::ScatterStyle | style | ) |
Sets the scatter style of the outlier data points.
void QCPlot::QCPStatisticalBox::setUpperQuartile | ( | double | value | ) |
Sets the parameter "upper Quartile" of the statistical box plot.
This is the upper end of the box. The lower and the upper quartiles are the two statistical quartiles around the median of the sample, they contain 50% of the sample data.
void QCPlot::QCPStatisticalBox::setWhiskerBarPen | ( | const QPen & | pen | ) |
Sets the pen used for drawing the whisker bars (Those are the lines parallel to the key axis at each end of the backbone).
void QCPlot::QCPStatisticalBox::setWhiskerPen | ( | const QPen & | pen | ) |
Sets the pen used for drawing the whisker backbone (That's the line parallel to the value axis).
Make sure to set the pen capStyle to Qt::FlatCap to prevent the backbone from reaching a few pixels past the bars, when using a non-zero pen width.
void QCPlot::QCPStatisticalBox::setWhiskerWidth | ( | double | width | ) |
Sets the width of the whiskers (setMinimum, setMaximum) in key coordinates.
void QCPlot::QCPStatisticalBox::setWidth | ( | double | width | ) |
Sets the width of the box in key coordinates.