iCub-main
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
QCPGraph Class Reference

A plottable representing a graph in a plot. More...

#include <qcustomplot.h>

+ Inheritance diagram for QCPGraph:

Public Types

enum  LineStyle {
  lsNone ,
  lsLine ,
  lsStepLeft ,
  lsStepRight ,
  lsStepCenter ,
  lsImpulse
}
 Defines how the graph's line is represented visually in the plot. More...
 
enum  ErrorType {
  etNone ,
  etKey ,
  etValue ,
  etBoth
}
 Defines what kind of error bars are drawn for each data point. More...
 

Public Member Functions

 QCPGraph (QCPAxis *keyAxis, QCPAxis *valueAxis)
 Constructs a graph which uses keyAxis as its key axis ("x") and valueAxis as its value axis ("y").
 
virtual ~QCPGraph ()
 
QCPDataMapdata () const
 Returns a pointer to the internal data storage of type QCPDataMap.
 
LineStyle lineStyle () const
 
QCPScatterStyle scatterStyle () const
 
ErrorType errorType () const
 
QPen errorPen () const
 
double errorBarSize () const
 
bool errorBarSkipSymbol () const
 
QCPGraphchannelFillGraph () const
 
bool adaptiveSampling () const
 
void setData (QCPDataMap *data, bool copy=false)
 Replaces the current data with the provided data.
 
void setData (const QVector< double > &key, const QVector< double > &value)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Replaces the current data with the provided points in key and value pairs.
 
void setDataKeyError (const QVector< double > &key, const QVector< double > &value, const QVector< double > &keyError)
 Replaces the current data with the provided points in key and value pairs.
 
void setDataKeyError (const QVector< double > &key, const QVector< double > &value, const QVector< double > &keyErrorMinus, const QVector< double > &keyErrorPlus)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Replaces the current data with the provided points in key and value pairs.
 
void setDataValueError (const QVector< double > &key, const QVector< double > &value, const QVector< double > &valueError)
 Replaces the current data with the provided points in key and value pairs.
 
void setDataValueError (const QVector< double > &key, const QVector< double > &value, const QVector< double > &valueErrorMinus, const QVector< double > &valueErrorPlus)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Replaces the current data with the provided points in key and value pairs.
 
void setDataBothError (const QVector< double > &key, const QVector< double > &value, const QVector< double > &keyError, const QVector< double > &valueError)
 Replaces the current data with the provided points in key and value pairs.
 
void setDataBothError (const QVector< double > &key, const QVector< double > &value, const QVector< double > &keyErrorMinus, const QVector< double > &keyErrorPlus, const QVector< double > &valueErrorMinus, const QVector< double > &valueErrorPlus)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Replaces the current data with the provided points in key and value pairs.
 
void setLineStyle (LineStyle ls)
 Sets how the single data points are connected in the plot.
 
void setScatterStyle (const QCPScatterStyle &style)
 Sets the visual appearance of single data points in the plot.
 
void setErrorType (ErrorType errorType)
 Sets which kind of error bars (Key Error, Value Error or both) should be drawn on each data point.
 
void setErrorPen (const QPen &pen)
 Sets the pen with which the error bars will be drawn.
 
void setErrorBarSize (double size)
 Sets the width of the handles at both ends of an error bar in pixels.
 
void setErrorBarSkipSymbol (bool enabled)
 If enabled is set to true, the error bar will not be drawn as a solid line under the scatter symbol but leave some free space around the symbol.
 
void setChannelFillGraph (QCPGraph *targetGraph)
 Sets the target graph for filling the area between this graph and targetGraph with the current brush (setBrush).
 
void setAdaptiveSampling (bool enabled)
 Sets whether adaptive sampling shall be used when plotting this graph.
 
void addData (const QCPDataMap &dataMap)
 Adds the provided data points in dataMap to the current data.
 
void addData (const QCPData &data)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Adds the provided single data point in data to the current data.
 
void addData (double key, double value)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Adds the provided single data point as key and value pair to the current data.
 
void addData (const QVector< double > &keys, const QVector< double > &values)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Adds the provided data points as key and value pairs to the current data.
 
void removeDataBefore (double key)
 Removes all data points with keys smaller than key.
 
void removeDataAfter (double key)
 Removes all data points with keys greater than key.
 
void removeData (double fromKey, double toKey)
 Removes all data points with keys between fromKey and toKey.
 
void removeData (double key)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Removes a single data point at key.
 
virtual void clearData ()
 Removes all data points.
 
virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const
 This function is used to decide whether a click hits a layerable object or not.
 
void rescaleAxes (bool onlyEnlarge, bool includeErrorBars) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Allows to define whether error bars are taken into consideration when determining the new axis range.
 
void rescaleKeyAxis (bool onlyEnlarge, bool includeErrorBars) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Allows to define whether error bars (of kind QCPGraph::etKey) are taken into consideration when determining the new axis range.
 
void rescaleValueAxis (bool onlyEnlarge, bool includeErrorBars) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Allows to define whether error bars (of kind QCPGraph::etValue) are taken into consideration when determining the new axis range.
 
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.
 
void rescaleKeyAxis (bool onlyEnlarge=false) const
 Rescales the key axis of the plottable so the whole plottable is visible.
 
void rescaleValueAxis (bool onlyEnlarge=false) const
 Rescales the value axis of the plottable so the whole plottable is visible.
 
- Public Member Functions inherited from QCPAbstractPlottable
 QCPAbstractPlottable (QCPAxis *keyAxis, QCPAxis *valueAxis)
 Constructs an abstract plottable which uses keyAxis as its key axis ("x") and valueAxis as its value axis ("y").
 
QString name () const
 
bool antialiasedFill () const
 
bool antialiasedScatters () const
 
bool antialiasedErrorBars () const
 
QPen pen () const
 
QPen selectedPen () const
 
QBrush brush () const
 
QBrush selectedBrush () const
 
QCPAxiskeyAxis () const
 
QCPAxisvalueAxis () 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 legend (QCPLegend).
 
void setAntialiasedFill (bool enabled)
 Sets whether fills of this plottable is drawn antialiased or not.
 
void setAntialiasedScatters (bool enabled)
 Sets whether the scatter symbols of this plottable are drawn antialiased or not.
 
void setAntialiasedErrorBars (bool enabled)
 Sets whether the error bars of this plottable are drawn antialiased or not.
 
void setPen (const QPen &pen)
 The pen is used to draw basic lines that make up the plottable representation in the plot.
 
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.
 
void setBrush (const QBrush &brush)
 The brush is used to draw basic fills of the plottable representation in the plot.
 
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.
 
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.
 
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.
 
Q_SLOT void setSelectable (bool selectable)
 Sets whether the user can (de-)select this plottable by clicking on the QCustomPlot surface.
 
Q_SLOT void setSelected (bool selected)
 Sets whether this plottable is selected or not.
 
virtual bool addToLegend ()
 Adds this plottable to the legend of the parent QCustomPlot (QCustomPlot::legend).
 
virtual bool removeFromLegend () const
 Removes the plottable from the legend of the parent QCustomPlot.
 
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.
 
void rescaleKeyAxis (bool onlyEnlarge=false) const
 Rescales the key axis of the plottable so the whole plottable is visible.
 
void rescaleValueAxis (bool onlyEnlarge=false) const
 Rescales the value axis of the plottable so the whole plottable is visible.
 
- Public Member Functions inherited from QCPLayerable
 QCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0)
 Creates a new QCPLayerable instance.
 
 ~QCPLayerable ()
 
bool visible () const
 
QCustomPlotparentPlot () const
 
QCPLayerableparentLayerable () const
 Returns the parent layerable of this layerable.
 
QCPLayerlayer () const
 
bool antialiased () const
 
void setVisible (bool on)
 Sets the visibility of this layerable object.
 
Q_SLOT bool setLayer (QCPLayer *layer)
 Sets the layer of this layerable object.
 
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.
 
void setAntialiased (bool enabled)
 Sets whether this object will be drawn antialiased or not.
 
bool realVisibility () const
 Returns whether this layerable is visible, taking the visibility of the layerable parent and the visibility of the layer this layerable is on into account.
 

Protected Member Functions

virtual void draw (QCPPainter *painter)
 
virtual void drawLegendIcon (QCPPainter *painter, const QRectF &rect) const
 
virtual QCPRange getKeyRange (bool &foundRange, SignDomain inSignDomain=sdBoth) const
 
virtual QCPRange getValueRange (bool &foundRange, SignDomain inSignDomain=sdBoth) const
 
virtual QCPRange getKeyRange (bool &foundRange, SignDomain inSignDomain, bool includeErrors) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Allows to specify whether the error bars should be included in the range calculation.
 
virtual QCPRange getValueRange (bool &foundRange, SignDomain inSignDomain, bool includeErrors) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Allows to specify whether the error bars should be included in the range calculation.
 
virtual void drawFill (QCPPainter *painter, QVector< QPointF > *lineData) const
 
virtual void drawScatterPlot (QCPPainter *painter, QVector< QCPData > *scatterData) const
 
virtual void drawLinePlot (QCPPainter *painter, QVector< QPointF > *lineData) const
 
virtual void drawImpulsePlot (QCPPainter *painter, QVector< QPointF > *lineData) const
 
void getPreparedData (QVector< QCPData > *lineData, QVector< QCPData > *scatterData) const
 
void getPlotData (QVector< QPointF > *lineData, QVector< QCPData > *scatterData) const
 
void getScatterPlotData (QVector< QCPData > *scatterData) const
 
void getLinePlotData (QVector< QPointF > *linePixelData, QVector< QCPData > *scatterData) const
 
void getStepLeftPlotData (QVector< QPointF > *linePixelData, QVector< QCPData > *scatterData) const
 
void getStepRightPlotData (QVector< QPointF > *linePixelData, QVector< QCPData > *scatterData) const
 
void getStepCenterPlotData (QVector< QPointF > *linePixelData, QVector< QCPData > *scatterData) const
 
void getImpulsePlotData (QVector< QPointF > *linePixelData, QVector< QCPData > *scatterData) const
 
void drawError (QCPPainter *painter, double x, double y, const QCPData &data) const
 
void getVisibleDataBounds (QCPDataMap::const_iterator &lower, QCPDataMap::const_iterator &upper) const
 
int countDataInBounds (const QCPDataMap::const_iterator &lower, const QCPDataMap::const_iterator &upper, int maxCount) const
 
void addFillBasePoints (QVector< QPointF > *lineData) const
 
void removeFillBasePoints (QVector< QPointF > *lineData) const
 
QPointF lowerFillBasePoint (double lowerKey) const
 
QPointF upperFillBasePoint (double upperKey) const
 
const QPolygonF getChannelFillPolygon (const QVector< QPointF > *lineData) const
 
int findIndexBelowX (const QVector< QPointF > *data, double x) const
 
int findIndexAboveX (const QVector< QPointF > *data, double x) const
 
int findIndexBelowY (const QVector< QPointF > *data, double y) const
 
int findIndexAboveY (const QVector< QPointF > *data, double y) const
 
double pointDistance (const QPointF &pixelPoint) const
 
- Protected Member Functions inherited from QCPAbstractPlottable
virtual QRect clipRect () const
 
virtual QCP::Interaction selectionCategory () const
 
void applyDefaultAntialiasingHint (QCPPainter *painter) const
 
virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
 
virtual void deselectEvent (bool *selectionStateChanged)
 
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 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
 
- Protected Member Functions inherited from QCPLayerable
virtual void parentPlotInitialized (QCustomPlot *parentPlot)
 
void initializeParentPlot (QCustomPlot *parentPlot)
 
void setParentLayerable (QCPLayerable *parentLayerable)
 
bool moveToLayer (QCPLayer *layer, bool prepend)
 
void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
 

Protected Attributes

QCPDataMapmData
 
QPen mErrorPen
 
LineStyle mLineStyle
 
QCPScatterStyle mScatterStyle
 
ErrorType mErrorType
 
double mErrorBarSize
 
bool mErrorBarSkipSymbol
 
QPointer< QCPGraphmChannelFillGraph
 
bool mAdaptiveSampling
 
- Protected Attributes inherited from QCPAbstractPlottable
QString mName
 
bool mAntialiasedFill
 
bool mAntialiasedScatters
 
bool mAntialiasedErrorBars
 
QPen mPen
 
QPen mSelectedPen
 
QBrush mBrush
 
QBrush mSelectedBrush
 
QPointer< QCPAxismKeyAxis
 
QPointer< QCPAxismValueAxis
 
bool mSelectable
 
bool mSelected
 
- Protected Attributes inherited from QCPLayerable
bool mVisible
 
QCustomPlotmParentPlot
 
QPointer< QCPLayerablemParentLayerable
 
QCPLayermLayer
 
bool mAntialiased
 

Friends

class QCustomPlot
 
class QCPLegend
 

Additional Inherited Members

- Signals inherited from QCPAbstractPlottable
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.
 
void selectableChanged (bool selectable)
 This signal is emitted when the selectability of this plottable has changed.
 
- Signals inherited from QCPLayerable
void layerChanged (QCPLayer *newLayer)
 This signal is emitted when the layer of this layerable changes, i.e.
 
- Protected Types inherited from QCPAbstractPlottable
enum  SignDomain {
  sdNegative ,
  sdBoth ,
  sdPositive
}
 Represents negative and positive sign domain for passing to getKeyRange and getValueRange. More...
 

Detailed Description

A plottable representing a graph in a plot.

Usually QCustomPlot creates graphs internally via QCustomPlot::addGraph and the resulting instance is accessed via QCustomPlot::graph.

To plot data, assign it with the setData or addData functions. Alternatively, you can also access and modify the graph's data via the data method, which returns a pointer to the internal QCPDataMap.

Graphs are used to display single-valued data. Single-valued means that there should only be one data point per unique key coordinate. In other words, the graph can't have loops. If you do want to plot non-single-valued curves, rather use the QCPCurve plottable.

Changing the appearance

The appearance of the graph is mainly determined by the line style, scatter style, brush and pen of the graph (setLineStyle, setScatterStyle, setBrush, setPen).

Filling under or between graphs

QCPGraph knows two types of fills: Normal graph fills towards the zero-value-line parallel to the key axis of the graph, and fills between two graphs, called channel fills. To enable a fill, just set a brush with setBrush which is neither Qt::NoBrush nor fully transparent.

By default, a normal fill towards the zero-value-line will be drawn. To set up a channel fill between this graph and another one, call setChannelFillGraph with the other graph as parameter.

See also
QCustomPlot::addGraph, QCustomPlot::graph, QCPLegend::addGraph

Definition at line 2466 of file qcustomplot.h.

Member Enumeration Documentation

◆ ErrorType

Defines what kind of error bars are drawn for each data point.

Enumerator
etNone 

No error bars are shown.

etKey 

Error bars for the key dimension of the data point are shown.

etValue 

Error bars for the value dimension of the data point are shown.

etBoth 

Error bars for both key and value dimensions of the data point are shown.

Definition at line 2497 of file qcustomplot.h.

◆ LineStyle

Defines how the graph's line is represented visually in the plot.

The line is drawn with the current pen of the graph (setPen).

See also
setLineStyle
Enumerator
lsNone 

data points are not connected with any lines (e.g.

data only represented with symbols according to the scatter style, see setScatterStyle)

lsLine 

data points are connected by a straight line

lsStepLeft 

line is drawn as steps where the step height is the value of the left data point

lsStepRight 

line is drawn as steps where the step height is the value of the right data point

lsStepCenter 

line is drawn as steps where the step is in between two data points

lsImpulse 

each data point is represented by a line parallel to the value axis, which reaches from the data point to the zero-value-line

Definition at line 2485 of file qcustomplot.h.

Constructor & Destructor Documentation

◆ QCPGraph()

QCPGraph::QCPGraph ( QCPAxis keyAxis,
QCPAxis valueAxis 
)
explicit

Constructs a graph 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 QCPGraph can be added to the plot with QCustomPlot::addPlottable, QCustomPlot then takes ownership of the graph.

To directly create a graph inside a plot, you can also use the simpler QCustomPlot::addGraph function.

Definition at line 14500 of file qcustomplot.cpp.

◆ ~QCPGraph()

QCPGraph::~QCPGraph ( )
virtual

Definition at line 14519 of file qcustomplot.cpp.

Member Function Documentation

◆ adaptiveSampling()

bool QCPGraph::adaptiveSampling ( ) const
inline

Definition at line 2516 of file qcustomplot.h.

◆ addData() [1/4]

void QCPGraph::addData ( const QCPData data)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Adds the provided single data point in data to the current data.

Alternatively, you can also access and modify the graph's data via the data method, which returns a pointer to the internal QCPDataMap.

See also
removeData

Definition at line 14887 of file qcustomplot.cpp.

◆ addData() [2/4]

void QCPGraph::addData ( const QCPDataMap dataMap)

Adds the provided data points in dataMap to the current data.

Alternatively, you can also access and modify the graph's data via the data method, which returns a pointer to the internal QCPDataMap.

See also
removeData

Definition at line 14874 of file qcustomplot.cpp.

◆ addData() [3/4]

void QCPGraph::addData ( const QVector< double > &  keys,
const QVector< double > &  values 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Adds the provided data points as key and value pairs to the current data.

Alternatively, you can also access and modify the graph's data via the data method, which returns a pointer to the internal QCPDataMap.

See also
removeData

Definition at line 14916 of file qcustomplot.cpp.

◆ addData() [4/4]

void QCPGraph::addData ( double  key,
double  value 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Adds the provided single data point as key and value pair to the current data.

Alternatively, you can also access and modify the graph's data via the data method, which returns a pointer to the internal QCPDataMap.

See also
removeData

Definition at line 14900 of file qcustomplot.cpp.

◆ addFillBasePoints()

void QCPGraph::addFillBasePoints ( QVector< QPointF > *  lineData) const
protected

Definition at line 15997 of file qcustomplot.cpp.

◆ channelFillGraph()

QCPGraph * QCPGraph::channelFillGraph ( ) const
inline

Definition at line 2515 of file qcustomplot.h.

◆ clearData()

void QCPGraph::clearData ( )
virtual

Removes all data points.

See also
removeData, removeDataAfter, removeDataBefore

Implements QCPAbstractPlottable.

Definition at line 14984 of file qcustomplot.cpp.

◆ countDataInBounds()

int QCPGraph::countDataInBounds ( const QCPDataMap::const_iterator &  lower,
const QCPDataMap::const_iterator &  upper,
int  maxCount 
) const
protected

Definition at line 15968 of file qcustomplot.cpp.

◆ data()

QCPDataMap * QCPGraph::data ( ) const
inline

Returns a pointer to the internal data storage of type QCPDataMap.

You may use it to directly manipulate the data, which may be more convenient and faster than using the regular setData or addData methods, in certain situations.

Definition at line 2508 of file qcustomplot.h.

◆ draw()

void QCPGraph::draw ( QCPPainter painter)
protectedvirtual

Implements QCPAbstractPlottable.

Definition at line 15089 of file qcustomplot.cpp.

◆ drawError()

void QCPGraph::drawError ( QCPPainter painter,
double  x,
double  y,
const QCPData data 
) const
protected

Definition at line 15829 of file qcustomplot.cpp.

◆ drawFill()

void QCPGraph::drawFill ( QCPPainter painter,
QVector< QPointF > *  lineData 
) const
protectedvirtual

Definition at line 15492 of file qcustomplot.cpp.

◆ drawImpulsePlot()

void QCPGraph::drawImpulsePlot ( QCPPainter painter,
QVector< QPointF > *  lineData 
) const
protectedvirtual

Definition at line 15615 of file qcustomplot.cpp.

◆ drawLegendIcon()

void QCPGraph::drawLegendIcon ( QCPPainter painter,
const QRectF &  rect 
) const
protectedvirtual

Implements QCPAbstractPlottable.

Definition at line 15136 of file qcustomplot.cpp.

◆ drawLinePlot()

void QCPGraph::drawLinePlot ( QCPPainter painter,
QVector< QPointF > *  lineData 
) const
protectedvirtual

Definition at line 15569 of file qcustomplot.cpp.

◆ drawScatterPlot()

void QCPGraph::drawScatterPlot ( QCPPainter painter,
QVector< QCPData > *  scatterData 
) const
protectedvirtual

Definition at line 15524 of file qcustomplot.cpp.

◆ errorBarSize()

double QCPGraph::errorBarSize ( ) const
inline

Definition at line 2513 of file qcustomplot.h.

◆ errorBarSkipSymbol()

bool QCPGraph::errorBarSkipSymbol ( ) const
inline

Definition at line 2514 of file qcustomplot.h.

◆ errorPen()

QPen QCPGraph::errorPen ( ) const
inline

Definition at line 2512 of file qcustomplot.h.

◆ errorType()

ErrorType QCPGraph::errorType ( ) const
inline

Definition at line 2511 of file qcustomplot.h.

◆ findIndexAboveX()

int QCPGraph::findIndexAboveX ( const QVector< QPointF > *  data,
double  x 
) const
protected

Definition at line 16305 of file qcustomplot.cpp.

◆ findIndexAboveY()

int QCPGraph::findIndexAboveY ( const QVector< QPointF > *  data,
double  y 
) const
protected

Definition at line 16349 of file qcustomplot.cpp.

◆ findIndexBelowX()

int QCPGraph::findIndexBelowX ( const QVector< QPointF > *  data,
double  x 
) const
protected

Definition at line 16327 of file qcustomplot.cpp.

◆ findIndexBelowY()

int QCPGraph::findIndexBelowY ( const QVector< QPointF > *  data,
double  y 
) const
protected

Definition at line 16447 of file qcustomplot.cpp.

◆ getChannelFillPolygon()

const QPolygonF QCPGraph::getChannelFillPolygon ( const QVector< QPointF > *  lineData) const
protected

Definition at line 16163 of file qcustomplot.cpp.

◆ getImpulsePlotData()

void QCPGraph::getImpulsePlotData ( QVector< QPointF > *  linePixelData,
QVector< QCPData > *  scatterData 
) const
protected

Definition at line 15440 of file qcustomplot.cpp.

◆ getKeyRange() [1/2]

QCPRange QCPGraph::getKeyRange ( bool &  foundRange,
SignDomain  inSignDomain,
bool  includeErrors 
) const
protectedvirtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Allows to specify whether the error bars should be included in the range calculation.

See also
getKeyRange(bool &foundRange, SignDomain inSignDomain)

Definition at line 16484 of file qcustomplot.cpp.

◆ getKeyRange() [2/2]

QCPRange QCPGraph::getKeyRange ( bool &  foundRange,
SignDomain  inSignDomain = sdBoth 
) const
protectedvirtual

Implements QCPAbstractPlottable.

Definition at line 16463 of file qcustomplot.cpp.

◆ getLinePlotData()

void QCPGraph::getLinePlotData ( QVector< QPointF > *  linePixelData,
QVector< QCPData > *  scatterData 
) const
protected

Definition at line 15228 of file qcustomplot.cpp.

◆ getPlotData()

void QCPGraph::getPlotData ( QVector< QPointF > *  lineData,
QVector< QCPData > *  scatterData 
) const
protected

Definition at line 15188 of file qcustomplot.cpp.

◆ getPreparedData()

void QCPGraph::getPreparedData ( QVector< QCPData > *  lineData,
QVector< QCPData > *  scatterData 
) const
protected

Definition at line 15641 of file qcustomplot.cpp.

◆ getScatterPlotData()

void QCPGraph::getScatterPlotData ( QVector< QCPData > *  scatterData) const
protected

Definition at line 15212 of file qcustomplot.cpp.

◆ getStepCenterPlotData()

void QCPGraph::getStepCenterPlotData ( QVector< QPointF > *  linePixelData,
QVector< QCPData > *  scatterData 
) const
protected

Definition at line 15375 of file qcustomplot.cpp.

◆ getStepLeftPlotData()

void QCPGraph::getStepLeftPlotData ( QVector< QPointF > *  linePixelData,
QVector< QCPData > *  scatterData 
) const
protected

Definition at line 15269 of file qcustomplot.cpp.

◆ getStepRightPlotData()

void QCPGraph::getStepRightPlotData ( QVector< QPointF > *  linePixelData,
QVector< QCPData > *  scatterData 
) const
protected

Definition at line 15322 of file qcustomplot.cpp.

◆ getValueRange() [1/2]

QCPRange QCPGraph::getValueRange ( bool &  foundRange,
SignDomain  inSignDomain,
bool  includeErrors 
) const
protectedvirtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Allows to specify whether the error bars should be included in the range calculation.

See also
getValueRange(bool &foundRange, SignDomain inSignDomain)

Definition at line 16590 of file qcustomplot.cpp.

◆ getValueRange() [2/2]

QCPRange QCPGraph::getValueRange ( bool &  foundRange,
SignDomain  inSignDomain = sdBoth 
) const
protectedvirtual

Implements QCPAbstractPlottable.

Definition at line 16471 of file qcustomplot.cpp.

◆ getVisibleDataBounds()

void QCPGraph::getVisibleDataBounds ( QCPDataMap::const_iterator &  lower,
QCPDataMap::const_iterator &  upper 
) const
protected

Definition at line 15938 of file qcustomplot.cpp.

◆ lineStyle()

LineStyle QCPGraph::lineStyle ( ) const
inline

Definition at line 2509 of file qcustomplot.h.

◆ lowerFillBasePoint()

QPointF QCPGraph::lowerFillBasePoint ( double  lowerKey) const
protected

Definition at line 16038 of file qcustomplot.cpp.

◆ pointDistance()

double QCPGraph::pointDistance ( const QPointF &  pixelPoint) const
protected

Definition at line 16374 of file qcustomplot.cpp.

◆ removeData() [1/2]

void QCPGraph::removeData ( double  fromKey,
double  toKey 
)

Removes all data points with keys between fromKey and toKey.

if fromKey is greater or equal to toKey, the function does nothing. To remove a single data point with known key, use removeData(double key).

See also
addData, clearData

Definition at line 14958 of file qcustomplot.cpp.

◆ removeData() [2/2]

void QCPGraph::removeData ( double  key)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Removes a single data point at key.

If the position is not known with absolute precision, consider using removeData(double fromKey, double toKey) with a small fuzziness interval around the suspected position, depeding on the precision with which the key is known.

See also
addData, clearData

Definition at line 14975 of file qcustomplot.cpp.

◆ removeDataAfter()

void QCPGraph::removeDataAfter ( double  key)

Removes all data points with keys greater than key.

See also
addData, clearData

Definition at line 14943 of file qcustomplot.cpp.

◆ removeDataBefore()

void QCPGraph::removeDataBefore ( double  key)

Removes all data points with keys smaller than key.

See also
addData, clearData

Definition at line 14932 of file qcustomplot.cpp.

◆ removeFillBasePoints()

void QCPGraph::removeFillBasePoints ( QVector< QPointF > *  lineData) const
protected

Definition at line 16019 of file qcustomplot.cpp.

◆ rescaleAxes() [1/2]

void QCPGraph::rescaleAxes ( bool  onlyEnlarge,
bool  includeErrorBars 
) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Allows to define whether error bars are taken into consideration when determining the new axis range.

See also
rescaleKeyAxis, rescaleValueAxis, QCPAbstractPlottable::rescaleAxes, QCustomPlot::rescaleAxes

Definition at line 15010 of file qcustomplot.cpp.

◆ rescaleAxes() [2/2]

void QCPAbstractPlottable::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.

If the scaling of an axis is logarithmic, rescaleAxes will make sure not to rescale to an illegal range i.e. a range containing different signs and/or zero. Instead it will stay in the current sign domain and ignore all parts of the plottable that lie outside of that domain.

onlyEnlarge makes sure the ranges are only expanded, never reduced. So it's possible to show multiple plottables in their entirety by multiple calls to rescaleAxes where the first call has onlyEnlarge set to false (the default), and all subsequent set to true.

See also
rescaleKeyAxis, rescaleValueAxis, QCustomPlot::rescaleAxes, QCPAxis::rescale

Definition at line 1429 of file qcustomplot.cpp.

◆ rescaleKeyAxis() [1/2]

void QCPGraph::rescaleKeyAxis ( bool  onlyEnlarge,
bool  includeErrorBars 
) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Allows to define whether error bars (of kind QCPGraph::etKey) are taken into consideration when determining the new axis range.

See also
rescaleAxes, QCPAbstractPlottable::rescaleKeyAxis

Definition at line 15023 of file qcustomplot.cpp.

◆ rescaleKeyAxis() [2/2]

void QCPAbstractPlottable::rescaleKeyAxis ( bool  onlyEnlarge = false) const

Rescales the key axis of the plottable so the whole plottable is visible.

See rescaleAxes for detailed behaviour.

Definition at line 1430 of file qcustomplot.cpp.

◆ rescaleValueAxis() [1/2]

void QCPGraph::rescaleValueAxis ( bool  onlyEnlarge,
bool  includeErrorBars 
) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Allows to define whether error bars (of kind QCPGraph::etValue) are taken into consideration when determining the new axis range.

See also
rescaleAxes, QCPAbstractPlottable::rescaleValueAxis

Definition at line 15059 of file qcustomplot.cpp.

◆ rescaleValueAxis() [2/2]

void QCPAbstractPlottable::rescaleValueAxis ( bool  onlyEnlarge = false) const

Rescales the value axis of the plottable so the whole plottable is visible.

Returns true if the axis was actually scaled. This might not be the case if this plottable has an invalid range, e.g. because it has no data points.

See rescaleAxes for detailed behaviour.

Definition at line 1431 of file qcustomplot.cpp.

◆ scatterStyle()

QCPScatterStyle QCPGraph::scatterStyle ( ) const
inline

Definition at line 2510 of file qcustomplot.h.

◆ selectTest()

double QCPGraph::selectTest ( const QPointF &  pos,
bool  onlySelectable,
QVariant *  details = 0 
) const
virtual

This function is used to decide whether a click hits a layerable object 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 object. If the object is either invisible or the distance couldn't be determined, -1.0 is returned. Further, if onlySelectable is true and the object is not selectable, -1.0 is returned, too.

If the item is represented not by single lines but by an area like QCPItemRect or QCPItemText, a click inside the area returns a constant value greater zero (typically the selectionTolerance of the parent QCustomPlot multiplied by 0.99). 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, and the finally selected object is notified via the selectEvent/deselectEvent methods.

details is an optional output parameter. Every layerable subclass may place any information in details. This information will be passed to selectEvent when the parent QCustomPlot decides on the basis of this selectTest call, that the object was successfully selected. The subsequent call to selectEvent will carry the details. This is useful for multi-part objects (like QCPAxis). This way, a possibly complex calculation to decide which part was clicked is only done once in selectTest. The result (i.e. the actually clicked part) can then be placed in details. So in the subsequent selectEvent, the decision which part was selected doesn't have to be done a second time for a single selection operation.

You may pass 0 as details to indicate that you are not interested in those selection details.

See also
selectEvent, deselectEvent, QCustomPlot::setInteractions

Implements QCPAbstractPlottable.

Definition at line 14990 of file qcustomplot.cpp.

◆ setAdaptiveSampling()

void QCPGraph::setAdaptiveSampling ( bool  enabled)

Sets whether adaptive sampling shall be used when plotting this graph.

QCustomPlot's adaptive sampling technique can drastically improve the replot performance for graphs with a larger number of points (e.g. above 10,000), without notably changing the appearance of the graph.

By default, adaptive sampling is enabled. Even if enabled, QCustomPlot decides whether adaptive sampling shall actually be used on a per-graph basis. So leaving adaptive sampling enabled has no disadvantage in almost all cases.

A line plot of 500,000 points without and with adaptive sampling

As can be seen, line plots experience no visual degradation from adaptive sampling. Outliers are reproduced reliably, as well as the overall shape of the data set. The replot time reduces dramatically though. This allows QCustomPlot to display large amounts of data in realtime.

A scatter plot of 100,000 points without and with adaptive sampling

Care must be taken when using high-density scatter plots in combination with adaptive sampling. The adaptive sampling algorithm treats scatter plots more carefully than line plots which still gives a significant reduction of replot times, but not quite as much as for line plots. This is because scatter plots inherently need more data points to be preserved in order to still resemble the original, non-adaptive-sampling plot. As shown above, the results still aren't quite identical, as banding occurs for the outer data points. This is in fact intentional, such that the boundaries of the data cloud stay visible to the viewer. How strong the banding appears, depends on the point density, i.e. the number of points in the plot.

For some situations with scatter plots it might thus be desirable to manually turn adaptive sampling off. For example, when saving the plot to disk. This can be achieved by setting enabled to false before issuing a command like QCustomPlot::savePng, and setting enabled back to true afterwards.

Definition at line 14861 of file qcustomplot.cpp.

◆ setChannelFillGraph()

void QCPGraph::setChannelFillGraph ( QCPGraph targetGraph)

Sets the target graph for filling the area between this graph and targetGraph with the current brush (setBrush).

When targetGraph is set to 0, a normal graph fill to the zero-value-line will be shown. To disable any filling, set the brush to Qt::NoBrush.

See also
setBrush

Definition at line 14810 of file qcustomplot.cpp.

◆ setData() [1/2]

void QCPGraph::setData ( const QVector< double > &  key,
const QVector< double > &  value 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Replaces the current data with the provided points in key and value pairs.

The provided vectors should have equal length. Else, the number of added points will be the size of the smallest vector.

Definition at line 14552 of file qcustomplot.cpp.

◆ setData() [2/2]

void QCPGraph::setData ( QCPDataMap data,
bool  copy = false 
)

Replaces the current data with the provided data.

If copy is set to true, data points in data will only be copied. if false, the graph takes ownership of the passed data and replaces the internal data pointer with it. This is significantly faster than copying for large datasets.

Alternatively, you can also access and modify the graph's data via the data method, which returns a pointer to the internal QCPDataMap.

Definition at line 14534 of file qcustomplot.cpp.

◆ setDataBothError() [1/2]

void QCPGraph::setDataBothError ( const QVector< double > &  key,
const QVector< double > &  value,
const QVector< double > &  keyError,
const QVector< double > &  valueError 
)

Replaces the current data with the provided points in key and value pairs.

Additionally the symmetrical key and value errors of the data points are set to the values in keyError and valueError. For error bars to show appropriately, see setErrorType. The provided vectors should have equal length. Else, the number of added points will be the size of the smallest vector.

For asymmetrical errors (plus different from minus), see the overloaded version of this function.

Definition at line 14681 of file qcustomplot.cpp.

◆ setDataBothError() [2/2]

void QCPGraph::setDataBothError ( const QVector< double > &  key,
const QVector< double > &  value,
const QVector< double > &  keyErrorMinus,
const QVector< double > &  keyErrorPlus,
const QVector< double > &  valueErrorMinus,
const QVector< double > &  valueErrorPlus 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Replaces the current data with the provided points in key and value pairs.

Additionally the negative key and value errors of the data points are set to the values in keyErrorMinus and valueErrorMinus. The positive key and value errors are set to the values in keyErrorPlus valueErrorPlus. For error bars to show appropriately, see setErrorType. The provided vectors should have equal length. Else, the number of added points will be the size of the smallest vector.

Definition at line 14710 of file qcustomplot.cpp.

◆ setDataKeyError() [1/2]

void QCPGraph::setDataKeyError ( const QVector< double > &  key,
const QVector< double > &  value,
const QVector< double > &  keyError 
)

Replaces the current data with the provided points in key and value pairs.

Additionally the symmetrical key error of the data points are set to the values in keyError. For error bars to show appropriately, see setErrorType. The provided vectors should have equal length. Else, the number of added points will be the size of the smallest vector.

For asymmetrical errors (plus different from minus), see the overloaded version of this function.

Definition at line 14628 of file qcustomplot.cpp.

◆ setDataKeyError() [2/2]

void QCPGraph::setDataKeyError ( const QVector< double > &  key,
const QVector< double > &  value,
const QVector< double > &  keyErrorMinus,
const QVector< double > &  keyErrorPlus 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Replaces the current data with the provided points in key and value pairs.

Additionally the negative key error of the data points are set to the values in keyErrorMinus, the positive key error to keyErrorPlus. For error bars to show appropriately, see setErrorType. The provided vectors should have equal length. Else, the number of added points will be the size of the smallest vector.

Definition at line 14654 of file qcustomplot.cpp.

◆ setDataValueError() [1/2]

void QCPGraph::setDataValueError ( const QVector< double > &  key,
const QVector< double > &  value,
const QVector< double > &  valueError 
)

Replaces the current data with the provided points in key and value pairs.

Additionally the symmetrical value error of the data points are set to the values in valueError. For error bars to show appropriately, see setErrorType. The provided vectors should have equal length. Else, the number of added points will be the size of the smallest vector.

For asymmetrical errors (plus different from minus), see the overloaded version of this function.

Definition at line 14575 of file qcustomplot.cpp.

◆ setDataValueError() [2/2]

void QCPGraph::setDataValueError ( const QVector< double > &  key,
const QVector< double > &  value,
const QVector< double > &  valueErrorMinus,
const QVector< double > &  valueErrorPlus 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Replaces the current data with the provided points in key and value pairs.

Additionally the negative value error of the data points are set to the values in valueErrorMinus, the positive value error to valueErrorPlus. For error bars to show appropriately, see setErrorType. The provided vectors should have equal length. Else, the number of added points will be the size of the smallest vector.

Definition at line 14601 of file qcustomplot.cpp.

◆ setErrorBarSize()

void QCPGraph::setErrorBarSize ( double  size)

Sets the width of the handles at both ends of an error bar in pixels.

Definition at line 14780 of file qcustomplot.cpp.

◆ setErrorBarSkipSymbol()

void QCPGraph::setErrorBarSkipSymbol ( bool  enabled)

If enabled is set to true, the error bar will not be drawn as a solid line under the scatter symbol but leave some free space around the symbol.

This feature uses the current scatter size (QCPScatterStyle::setSize) to determine the size of the area to leave blank. So when drawing Pixmaps as scatter points (QCPScatterStyle::ssPixmap), the scatter size must be set manually to a value corresponding to the size of the Pixmap, if the error bars should leave gaps to its boundaries.

setErrorType, setErrorBarSize, setScatterStyle

Definition at line 14796 of file qcustomplot.cpp.

◆ setErrorPen()

void QCPGraph::setErrorPen ( const QPen &  pen)

Sets the pen with which the error bars will be drawn.

See also
setErrorBarSize, setErrorType

Definition at line 14772 of file qcustomplot.cpp.

◆ setErrorType()

void QCPGraph::setErrorType ( ErrorType  errorType)

Sets which kind of error bars (Key Error, Value Error or both) should be drawn on each data point.

If you set errorType to something other than etNone, make sure to actually pass error data via the specific setData functions along with the data points (e.g. setDataValueError, setDataKeyError, setDataBothError).

See also
ErrorType

Definition at line 14763 of file qcustomplot.cpp.

◆ setLineStyle()

void QCPGraph::setLineStyle ( LineStyle  ls)

Sets how the single data points are connected in the plot.

For scatter-only plots, set ls to lsNone and setScatterStyle to the desired scatter style.

See also
setScatterStyle

Definition at line 14739 of file qcustomplot.cpp.

◆ setScatterStyle()

void QCPGraph::setScatterStyle ( const QCPScatterStyle style)

Sets the visual appearance of single data points in the plot.

If set to QCPScatterStyle::ssNone, no scatter points are drawn (e.g. for line-only-plots with appropriate line style).

See also
QCPScatterStyle, setLineStyle

Definition at line 14750 of file qcustomplot.cpp.

◆ upperFillBasePoint()

QPointF QCPGraph::upperFillBasePoint ( double  upperKey) const
protected

Definition at line 16103 of file qcustomplot.cpp.

Friends And Related Symbol Documentation

◆ QCPLegend

friend class QCPLegend
friend

Definition at line 2606 of file qcustomplot.h.

◆ QCustomPlot

friend class QCustomPlot
friend

Definition at line 2605 of file qcustomplot.h.

Member Data Documentation

◆ mAdaptiveSampling

bool QCPGraph::mAdaptiveSampling
protected

Definition at line 2566 of file qcustomplot.h.

◆ mChannelFillGraph

QPointer<QCPGraph> QCPGraph::mChannelFillGraph
protected

Definition at line 2565 of file qcustomplot.h.

◆ mData

QCPDataMap* QCPGraph::mData
protected

Definition at line 2558 of file qcustomplot.h.

◆ mErrorBarSize

double QCPGraph::mErrorBarSize
protected

Definition at line 2563 of file qcustomplot.h.

◆ mErrorBarSkipSymbol

bool QCPGraph::mErrorBarSkipSymbol
protected

Definition at line 2564 of file qcustomplot.h.

◆ mErrorPen

QPen QCPGraph::mErrorPen
protected

Definition at line 2559 of file qcustomplot.h.

◆ mErrorType

ErrorType QCPGraph::mErrorType
protected

Definition at line 2562 of file qcustomplot.h.

◆ mLineStyle

LineStyle QCPGraph::mLineStyle
protected

Definition at line 2560 of file qcustomplot.h.

◆ mScatterStyle

QCPScatterStyle QCPGraph::mScatterStyle
protected

Definition at line 2561 of file qcustomplot.h.


The documentation for this class was generated from the following files: