QWT API (English) 7.3.0
Qt Widget Library for Technical Applications - English API Documentation
Loading...
Searching...
No Matches
Classes | Public Types | Public Slots | Signals | Public Member Functions | Protected Member Functions | Properties | Friends | List of all members
QwtPlot Class Reference

A 2-D plotting widget. More...

#include <qwt_plot.h>

Inheritance diagram for QwtPlot:
QwtPlotDict

Classes

class  PrivateData
 
class  ScaleData
 

Public Types

enum  LegendPosition { LeftLegend , RightLegend , BottomLegend , TopLegend }
 Position of the legend, relative to the canvas. More...
 
enum  TickDirection { TickOutside = 0 , TickInside = 1 }
 Tick direction enum. More...
 
enum  Axis {
  yLeft = QwtAxis::YLeft , yRight = QwtAxis::YRight , xBottom = QwtAxis::XBottom , xTop = QwtAxis::XTop ,
  axisCnt = QwtAxis::AxisPositions
}
 

Public Slots

virtual void replot ()
 Redraw the plot.
 
void autoRefresh ()
 Replots the plot if autoReplot() is enabled.
 
virtual void replotAll ()
 Replot all plots.
 
void autoRefreshAll ()
 

Signals

void itemAttached (QwtPlotItem *plotItem, bool on)
 A signal indicating that an item has been attached/detached.
 
void legendDataChanged (const QVariant &itemInfo, const QList< QwtLegendData > &data)
 A signal with the attributes how to update the legend entries for a plot item.
 
void parasitePlotAttached (QwtPlot *parasitePlot, bool on)
 Identify the relationship between the parasitic plot and its host plot.
 

Public Member Functions

 QwtPlot (QWidget *=nullptr)
 Constructor.
 
 QwtPlot (const QwtText &title, QWidget *=nullptr)
 
void setAutoReplot (bool=true)
 Set or reset the autoReplot option.
 
bool autoReplot () const
 Check if autoReplot option is enabled.
 
QString plotId () const
 Plot ID.
 
void setPlotId (const QString &id)
 
void setPlotLayout (QwtPlotLayout *)
 Assign a new plot layout.
 
QwtPlotLayoutplotLayout ()
 Get the plot's layout.
 
const QwtPlotLayoutplotLayout () const
 Get the plot's layout.
 
void setTitle (const QString &)
 Change the plot's title.
 
void setTitle (const QwtText &)
 Change the plot's title.
 
QwtText title () const
 Get the plot's title.
 
QwtTextLabeltitleLabel ()
 Get the title label widget.
 
const QwtTextLabeltitleLabel () const
 Get the title label widget.
 
void setFooter (const QString &)
 Change the footer text.
 
void setFooter (const QwtText &)
 Change the footer text.
 
QwtText footer () const
 Get the footer text.
 
QwtTextLabelfooterLabel ()
 Get the footer label widget.
 
const QwtTextLabelfooterLabel () const
 Get the footer label widget.
 
void setCanvas (QWidget *)
 Set the drawing canvas of the plot widget.
 
QWidget * canvas ()
 Get the plot's canvas.
 
const QWidget * canvas () const
 Get the plot's canvas.
 
void setCanvasBackground (const QBrush &)
 Change the background of the plotting area.
 
QBrush canvasBackground () const
 Nothing else than: canvas()->palette().brush( QPalette::Normal, QPalette::Window);.
 
void setColorCycle (const QwtColorCycle &)
 Set the color cycle used for automatic item coloring.
 
QwtColorCycle colorCycle () const
 Get the current color cycle.
 
QColor nextColorForItem (int rtti)
 Get the next auto-assigned color for a plot item type.
 
virtual QwtScaleMap canvasMap (QwtAxisId) const
 
double invTransform (QwtAxisId, double pos) const
 Transform the x or y coordinate of a position in the drawing region into a value.
 
double transform (QwtAxisId, double value) const
 Transform a value into a coordinate in the plotting region.
 
bool isAxisValid (QwtAxisId) const
 Checks if an axis is valid.
 
void setAxisVisible (QwtAxisId, bool on=true)
 Hide or show a specified axis.
 
bool isAxisVisible (QwtAxisId) const
 Return whether the specified axis is visible.
 
QwtScaleEngineaxisScaleEngine (QwtAxisId)
 Return the scale engine for a specific axis.
 
const QwtScaleEngineaxisScaleEngine (QwtAxisId) const
 Return the scale engine for a specific axis (const overload)
 
void setAxisScaleEngine (QwtAxisId, QwtScaleEngine *)
 Change the scale engine for an axis.
 
void setAxisAutoScale (QwtAxisId, bool on=true)
 Enable autoscaling for a specified axis.
 
bool axisAutoScale (QwtAxisId) const
 Return whether autoscaling is enabled.
 
void setAxisFont (QwtAxisId, const QFont &)
 Change the font of an axis.
 
QFont axisFont (QwtAxisId) const
 Return the font of the scale labels for a specified axis.
 
void setAxisScale (QwtAxisId, double min, double max, double stepSize=0)
 Disable autoscaling and specify a fixed scale for a selected axis.
 
void setAxisScaleDiv (QwtAxisId, const QwtScaleDiv &)
 Disable autoscaling and specify a fixed scale for a selected axis.
 
void setAxisScaleDraw (QwtAxisId, QwtScaleDraw *)
 Set a scale draw.
 
double axisStepSize (QwtAxisId) const
 Return the step size parameter that has been set in setAxisScale.
 
QwtInterval axisInterval (QwtAxisId) const
 Return the current interval of the specified axis.
 
const QwtScaleDivaxisScaleDiv (QwtAxisId) const
 Return the scale division of a specified axis.
 
const QwtScaleDrawaxisScaleDraw (QwtAxisId) const
 Return the scale draw of a specified axis.
 
QwtScaleDrawaxisScaleDraw (QwtAxisId)
 Return the scale draw of a specified axis.
 
const QwtScaleWidgetaxisWidget (QwtAxisId) const
 Return the scale widget of the specified axis.
 
QwtScaleWidgetaxisWidget (QwtAxisId)
 Return the scale widget of the specified axis.
 
QwtAxisId visibleXAxisId () const
 Return the currently visible X axis.
 
QwtAxisId visibleYAxisId () const
 Return the currently usable Y axis.
 
void setAxisLabelAlignment (QwtAxisId, Qt::Alignment)
 Change the alignment of the tick labels.
 
void setAxisLabelRotation (QwtAxisId, double rotation)
 Rotate all tick labels.
 
void setAxisTitle (QwtAxisId, const QString &)
 Change the title of a specified axis.
 
void setAxisTitle (QwtAxisId, const QwtText &)
 Change the title of a specified axis.
 
QwtText axisTitle (QwtAxisId) const
 Get the title of a specified axis.
 
void setAxisMaxMinor (QwtAxisId, int maxMinor)
 Set the maximum number of minor scale intervals for a specified axis.
 
int axisMaxMinor (QwtAxisId) const
 Return the maximum number of minor ticks for a specified axis.
 
void setAxisMaxMajor (QwtAxisId, int maxMajor)
 Set the maximum number of major scale intervals for a specified axis.
 
int axisMaxMajor (QwtAxisId) const
 Return the maximum number of major ticks for a specified axis.
 
void setAxisTickDirection (QwtAxisId axisId, TickDirection direction)
 Set the tick direction for an axis.
 
TickDirection axisTickDirection (QwtAxisId axisId) const
 Get the tick direction for an axis.
 
void insertLegend (QwtAbstractLegend *, LegendPosition=QwtPlot::RightLegend, double ratio=-1.0)
 Insert a legend.
 
QwtAbstractLegendlegend ()
 Get the plot's legend.
 
const QwtAbstractLegendlegend () const
 Get the plot's legend.
 
void updateLegend ()
 Emit legendDataChanged() for all plot item.
 
void updateLegend (const QwtPlotItem *)
 Emit legendDataChanged() for a plot item.
 
virtual QSize sizeHint () const override
 
virtual QSize minimumSizeHint () const override
 Return a minimum size hint.
 
virtual void updateLayout ()
 Adjust plot content to its current size.
 
virtual void drawCanvas (QPainter *)
 Redraw the canvas.
 
void updateAxes ()
 Rebuild the axes scales.
 
void updateCanvasMargins ()
 Update the canvas margins.
 
virtual void getCanvasMarginsHint (const QwtScaleMap maps[], const QRectF &canvasRect, double &left, double &top, double &right, double &bottom) const
 Calculate the canvas margins.
 
virtual bool event (QEvent *) override
 Adds handling of layout requests.
 
virtual bool eventFilter (QObject *, QEvent *) override
 Event filter.
 
virtual void drawItems (QPainter *, const QRectF &, const QwtScaleMap maps[QwtAxis::AxisPositions]) const
 Redraw the canvas items.
 
virtual QVariant itemToInfo (QwtPlotItem *) const
 Build an information, that can be used to identify a plot item on the legend.
 
virtual QwtPlotIteminfoToItem (const QVariant &) const
 Identify the plot item according to an item info object, that has bee generated from itemToInfo().
 
QwtPlotcreateParasitePlot (QwtAxis::Position enableAxis)
 Create parasite axes for this plot.
 
void setParasiteShareAxis (QwtAxisId axisId, bool isShare=true)
 Set whether the parasite axis shares the host's specified axis, only valid for parasite axes.
 
bool isParasiteShareAxis (QwtAxisId axisId) const
 Query whether the parasite axis shares the host's specified axis.
 
void removeParasitePlot (QwtPlot *parasite)
 Remove a parasite plot from this host plot.
 
QList< QwtPlot * > parasitePlots () const
 Get all parasite plots associated with this host plot.
 
QList< QwtPlot * > plotList (bool descending=false) const
 Return all plots, including the host plot.
 
QwtPlotparasitePlotAt (int index) const
 Get the nth parasite plot.
 
int parasitePlotIndex (QwtPlot *parasite) const
 Parasite plot index (level)
 
QwtPlothostPlot () const
 Get the host plot for this parasite plot.
 
bool isParasitePlot () const
 Check if this plot is a parasite plot.
 
bool isTopParasitePlot () const
 Whether this is the topmost parasite plot; the topmost parasite's axes are at the outermost layer and are typically updated last.
 
bool isHostPlot () const
 Check if this plot is a host plot.
 
void setBackgroundColor (const QColor &c)
 Set background color.
 
QColor backgroundColor () const
 Get background color.
 
void syncAxis (QwtAxisId axis, const QwtPlot *plot)
 Synchronize the axis ranges from the given plot to this plot.
 
void rescaleAxes (bool onlyVisibleItems=true, double marginPercent=0.05, QwtAxisId xAxis=QwtPlot::xBottom, QwtAxisId yAxis=QwtPlot::yLeft)
 Rescale axes to fit all data items.
 
void setAxisToLogScale (QwtAxisId axisId)
 Set the specified axis to logarithmic scale.
 
void setAxisToDateTime (QwtAxisId axisId, Qt::TimeSpec timeSpec=Qt::LocalTime)
 Set the specified axis to date-time scale.
 
void setAxisToLinearScale (QwtAxisId axisId)
 Restore the specified axis to linear scale.
 
void alignToHost ()
 Align the parasite plot to the host plot.
 
int parasitePlotCount () const
 Get the number of parasite plots.
 
void updateAxisEdgeMargin (QwtAxisId axisId)
 Recalculate and assign edgeMargin and margin for all layers (host + parasite) axes based on level order.
 
void updateAllAxisEdgeMargin ()
 Batch update edge offsets for all axis positions.
 
void updateItemsToScaleDiv ()
 Update the scale range of all plot items to match the current axis scales.
 
void setEnableScaleBuildinActions (bool on)
 Enable or disable built-in axis event actions.
 
bool isEnableScaleBuildinActions () const
 Check if built-in axis event actions are enabled.
 
void setupScaleEventDispatcher (QwtPlotScaleEventDispatcher *dispatcher)
 Install the axis event dispatcher.
 
void saveAutoReplotState ()
 Save the current autoReplot state.
 
void restoreAutoReplotState ()
 Restore the previously saved autoReplot state.
 
void panAxis (QwtAxisId axisId, int deltaPixels)
 Pan the specified axis by a given number of pixels.
 
void panCanvas (const QPoint &offset)
 Pan the entire canvas by a pixel offset.
 
void zoomAxis (QwtAxisId axisId, double factor, const QPoint &centerPosPixels)
 Zoom the axis centered at the specified pixel position.
 
void enableAxis (int axisId, bool on=true)
 
bool axisEnabled (int axisId) const
 
- Public Member Functions inherited from QwtPlotDict
 QwtPlotDict ()
 Constructor.
 
void setAutoDelete (bool)
 Enable/disable auto deletion.
 
bool autoDelete () const
 Check if auto deletion is enabled.
 
const QwtPlotItemListitemList () const
 Get the list of all attached plot items.
 
QwtPlotItemList itemList (int rtti) const
 Get the list of all attached plot items of a specific type.
 
void detachItems (int rtti=QwtPlotItem::Rtti_PlotItem, bool autoDelete=true)
 Detach items from the dictionary.
 

Protected Member Functions

virtual void resizeEvent (QResizeEvent *) override
 Resize and update internal layout.
 
void addParasitePlot (QwtPlot *parasite)
 Add a parasite plot to this host plot.
 
void initParasiteAxes (QwtPlot *parasitePlot) const
 Initialize basic properties of the parasite axes.
 
void doLayout ()
 Adjust plot content to its current size.
 
void drawInsideTicks (QPainter *, const QRectF &canvasRect, const QwtScaleMap maps[QwtAxis::AxisPositions]) const
 Draw inside ticks for axes with TickInside direction.
 
- Protected Member Functions inherited from QwtPlotDict
void insertItem (QwtPlotItem *)
 Insert an item into the dictionary.
 
void removeItem (QwtPlotItem *)
 Remove an item from the dictionary.
 

Properties

QBrush canvasBackground
 
bool autoReplot
 

Friends

class QwtFigure
 
class QwtPlotItem
 

Detailed Description

A 2-D plotting widget.

QwtPlot is a widget for plotting two-dimensional graphs. An unlimited number of plot items can be displayed on its canvas. Plot items might be curves (QwtPlotCurve), markers (QwtPlotMarker), the grid (QwtPlotGrid), or anything else derived from QwtPlotItem. A plot can have up to four axes, with each plot item attached to an x- and a y axis. The scales at the axes can be explicitly set (QwtScaleDiv), or are calculated from the plot items, using algorithms (QwtScaleEngine) which can be configured separately for each axis.

The simpleplot example is a good starting point to see how to set up a plot widget.

Example
The following example shows (schematically) the most simple way to use QwtPlot. By default, only the left and bottom axes are visible and their scales are computed automatically.
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
QwtPlot *myPlot = new QwtPlot( "Two Curves", parent );
// add curves
QwtPlotCurve *curve1 = new QwtPlotCurve( "Curve 1" );
QwtPlotCurve *curve2 = new QwtPlotCurve( "Curve 2" );
// connect or copy the data to the curves
curve1->setData( ... );
curve2->setData( ... );
curve1->attach( myPlot );
curve2->attach( myPlot );
// finally, refresh the plot
myPlot->replot();
A plot item, that represents a series of points.
Definition qwt_plot_curve.h:75
void attach(QwtPlot *plot) override
Attach the curve to a plot.
Definition qwt_plot_curve.cpp:164
A 2-D plotting widget.
Definition qwt_plot.h:99
virtual void replot()
Redraw the plot.
Definition qwt_plot.cpp:670

Member Enumeration Documentation

◆ LegendPosition

Position of the legend, relative to the canvas.

See also
insertLegend()
Enumerator
LeftLegend 

The legend will be left from the QwtAxis::YLeft axis.

The legend will be right from the QwtAxis::YRight axis

RightLegend 

The legend will be below the footer.

BottomLegend 

The legend will be above the title.

◆ TickDirection

Tick direction enum.

Controls whether ticks are drawn inside or outside the canvas. When ticks are inside, they are drawn from the canvas edge toward the interior, while the backbone and labels remain outside.

Enumerator
TickOutside 

Ticks are drawn outside the canvas (default behavior)

Ticks are drawn inside the canvas

Constructor & Destructor Documentation

◆ QwtPlot()

QwtPlot::QwtPlot ( QWidget *  parent = nullptr)
explicit

Constructor.

Parameters
[in]parentParent widget

Creates a QwtPlot widget with an empty title.

Constructor with title

Parameters
[in]titleTitle text
[in]parentParent widget

Creates a QwtPlot widget with the specified title.

Destructor

Detaches all plot items and deletes the layout and axis data.

Member Function Documentation

◆ addParasitePlot()

void QwtPlot::addParasitePlot ( QwtPlot parasite)
protected

Add a parasite plot to this host plot.

This method establishes a parasite relationship where the specified plot will be treated as a parasite of this host plot. The parasite plot will automatically synchronize its geometry with the host plot.

Parameters
parasitePointer to the parasite QwtPlot
Note
This method is typically called internally by QwtFigure::createParasiteAxes().
The parasite plot should have a transparent background to avoid obscuring the host plot.
// Manually create a parasite relationship
QwtPlot* parasitePlot = new QwtPlot;
// Configure parasite plot
parasitePlot->setAutoFillBackground(false);
parasitePlot->canvas()->setAutoFillBackground(false);
parasitePlot->enableAxis(QwtAxis::YRight, true);
// Add parasite to host
hostPlot->addParasitePlot(parasitePlot);
QWidget * canvas()
Get the plot's canvas.
Definition qwt_plot.cpp:588
void addParasitePlot(QwtPlot *parasite)
Add a parasite plot to this host plot.
Definition qwt_plot.cpp:1505
QwtPlot * hostPlot() const
Get the host plot for this parasite plot.
Definition qwt_plot.cpp:1669
@ YRight
Y axis right of the canvas.
Definition qwt_axis.h:48
See also
removeParasitePlot(), parasitePlots()

◆ autoRefresh

void QwtPlot::autoRefresh ( )
slot

Replots the plot if autoReplot() is enabled.

This method is called internally when plot properties change and autoReplot is enabled.

◆ autoReplot()

bool QwtPlot::autoReplot ( ) const

Check if autoReplot option is enabled.

Returns
true if the autoReplot option is set
See also
setAutoReplot()

◆ axisAutoScale()

bool QwtPlot::axisAutoScale ( QwtAxisId  axisId) const

Return whether autoscaling is enabled.

Parameters
axisIdAxis ID
Returns
true if autoscaling is enabled

◆ axisFont()

QFont QwtPlot::axisFont ( QwtAxisId  axisId) const

Return the font of the scale labels for a specified axis.

Parameters
axisIdAxis ID
Returns
Font

◆ axisInterval()

QwtInterval QwtPlot::axisInterval ( QwtAxisId  axisId) const

Return the current interval of the specified axis.

This is only a convenience function for axisScaleDiv( axisId )->interval();

Parameters
axisIdAxis ID
Returns
Scale interval
See also
QwtScaleDiv, axisScaleDiv()

◆ axisMaxMajor()

int QwtPlot::axisMaxMajor ( QwtAxisId  axisId) const

Return the maximum number of major ticks for a specified axis.

Parameters
axisIdAxis ID
See also
setAxisMaxMajor(), QwtScaleEngine::divideScale()

◆ axisMaxMinor()

int QwtPlot::axisMaxMinor ( QwtAxisId  axisId) const

Return the maximum number of minor ticks for a specified axis.

Parameters
axisIdAxis ID
See also
setAxisMaxMinor(), QwtScaleEngine::divideScale()

◆ axisScaleDiv()

const QwtScaleDiv & QwtPlot::axisScaleDiv ( QwtAxisId  axisId) const

Return the scale division of a specified axis.

axisScaleDiv(axisId).lowerBound(), axisScaleDiv(axisId).upperBound() are the current limits of the axis scale.

Parameters
axisIdAxis ID
Returns
Scale division
See also
QwtScaleDiv, setAxisScaleDiv(), QwtScaleEngine::divideScale()

◆ axisScaleDraw() [1/2]

QwtScaleDraw * QwtPlot::axisScaleDraw ( QwtAxisId  axisId)

Return the scale draw of a specified axis.

Parameters
axisIdAxis ID
Returns
Specified scaleDraw for axis, or nullptr if axis is invalid.

◆ axisScaleDraw() [2/2]

const QwtScaleDraw * QwtPlot::axisScaleDraw ( QwtAxisId  axisId) const

Return the scale draw of a specified axis.

Parameters
axisIdAxis ID
Returns
Specified scaleDraw for axis, or nullptr if axis is invalid.

◆ axisScaleEngine() [1/2]

QwtScaleEngine * QwtPlot::axisScaleEngine ( QwtAxisId  axisId)

Return the scale engine for a specific axis.

Parameters
axisIdAxis ID
Returns
Scale engine

◆ axisScaleEngine() [2/2]

const QwtScaleEngine * QwtPlot::axisScaleEngine ( QwtAxisId  axisId) const

Return the scale engine for a specific axis (const overload)

Parameters
axisIdAxis ID
Returns
Scale engine

◆ axisStepSize()

double QwtPlot::axisStepSize ( QwtAxisId  axisId) const

Return the step size parameter that has been set in setAxisScale.

This doesn't need to be the step size of the current scale.

Parameters
axisIdAxis ID
Returns
step size parameter value
See also
setAxisScale(), QwtScaleEngine::divideScale()

◆ axisTickDirection()

QwtPlot::TickDirection QwtPlot::axisTickDirection ( QwtAxisId  axisId) const

Get the tick direction for an axis.

Parameters
axisIdAxis identifier
Returns
Current tick direction
See also
setAxisTickDirection()

◆ axisTitle()

QwtText QwtPlot::axisTitle ( QwtAxisId  axisId) const

Get the title of a specified axis.

Parameters
axisIdAxis ID
Returns
Title of a specified axis

◆ axisWidget() [1/2]

QwtScaleWidget * QwtPlot::axisWidget ( QwtAxisId  axisId)

Return the scale widget of the specified axis.

Parameters
axisIdAxis ID
Returns
Scale widget, or nullptr if axisId is invalid

◆ axisWidget() [2/2]

const QwtScaleWidget * QwtPlot::axisWidget ( QwtAxisId  axisId) const

Return the scale widget of the specified axis.

Parameters
axisIdAxis ID
Returns
Scale widget, or nullptr if axisId is invalid

◆ backgroundColor()

QColor QwtPlot::backgroundColor ( ) const

Get background color.

Returns
Background color

◆ canvas() [1/2]

QWidget * QwtPlot::canvas ( )

Get the plot's canvas.

Returns
The plot's canvas widget

◆ canvas() [2/2]

const QWidget * QwtPlot::canvas ( ) const

Get the plot's canvas.

Returns
The plot's canvas widget (const)

◆ canvasBackground()

QBrush QwtPlot::canvasBackground ( ) const

Nothing else than: canvas()->palette().brush( QPalette::Normal, QPalette::Window);.

Returns
Background brush of the plotting area.
See also
setCanvasBackground()

◆ canvasMap()

QwtScaleMap QwtPlot::canvasMap ( QwtAxisId  axisId) const
virtual
Parameters
axisIdAxis
Returns
Map for the axis on the canvas. With this map pixel coordinates can translated to plot coordinates and vice versa.
See also
QwtScaleMap, transform(), invTransform()

◆ colorCycle()

QwtColorCycle QwtPlot::colorCycle ( ) const

Get the current color cycle.

Returns
Current color cycle
See also
setColorCycle()

◆ createParasitePlot()

QwtPlot * QwtPlot::createParasitePlot ( QwtAxis::Position  enableAxis)

Create parasite axes for this plot.

This method creates a parasite axes that shares the same plotting area as the host plot but with independent axis scaling and labeling. The parasite axes will be positioned exactly on top of the host plot and will automatically synchronize its geometry.

Parameters
enableAxisThe axis position to enable on the parasite axes
Returns
Pointer to the created parasite QwtPlot
Return values
nullptrif hostPlot is invalid or not in the figure
Note
A plot cannot be both a parasite and a host at the same time. That is, if a plot is a parasite plot, it is not allowed to create further parasite plots. Calling this function on a parasite plot will return nullptr.

◆ doLayout()

void QwtPlot::doLayout ( )
protected

Adjust plot content to its current size.

The concrete implementation of updateLayout. Before version 7.0, there were no parasite axes. Since the size information of parasite axes fully references the host axes, during the updateLayout process, parasite axes should not perform any actions. Instead, after the host axis's updateLayout finishes, doLayout is executed for all parasite axes.

Therefore, all implementation of updateLayout is extracted into doLayout.

◆ drawCanvas()

void QwtPlot::drawCanvas ( QPainter *  painter)
virtual

Redraw the canvas.

Parameters
painterPainter used for drawing
Warning
drawCanvas calls drawItems what is also used for printing. Applications that like to add individual plot items better overload drawItems()
See also
drawItems()

◆ drawInsideTicks()

void QwtPlot::drawInsideTicks ( QPainter *  painter,
const QRectF &  canvasRect,
const QwtScaleMap  maps[QwtAxis::AxisPositions] 
) const
protected

Draw inside ticks for axes with TickInside direction.

This method is called after drawItems() to draw tick marks that extend from the canvas edge toward the interior.

Parameters
painterPainter
canvasRectCanvas rectangle
mapsScale maps for all axes

◆ drawItems()

void QwtPlot::drawItems ( QPainter *  painter,
const QRectF &  canvasRect,
const QwtScaleMap  maps[QwtAxis::AxisPositions] 
) const
virtual

Redraw the canvas items.

Parameters
painterPainter used for drawing
canvasRectBounding rectangle where to paint
mapsQwtAxis::AxisCount maps, mapping between plot and paint device coordinates
Note
Usually canvasRect is contentsRect() of the plot canvas. Due to a bug in Qt this rectangle might be wrong for certain frame styles ( f.e QFrame::Box ) and it might be necessary to fix the margins manually using QWidget::setContentsMargins()

◆ event()

bool QwtPlot::event ( QEvent *  event)
overridevirtual

Adds handling of layout requests.

Parameters
eventEvent
Returns
See QFrame::event()

◆ eventFilter()

bool QwtPlot::eventFilter ( QObject *  object,
QEvent *  e 
)
overridevirtual

Event filter.

The plot handles the following events for the canvas:

  • QEvent::Resize The canvas margins might depend on its size
  • QEvent::ContentsRectChange The layout needs to be recalculated
  • For parasite axes, the parasite axis filters the host axis dimensions and adjusts its own dimensions
Parameters
objectObject to be filtered
eventEvent
Returns
See QFrame::eventFilter()
See also
updateCanvasMargins(), updateLayout()

◆ footer()

QwtText QwtPlot::footer ( ) const

Get the footer text.

Returns
Text of the footer

◆ footerLabel() [1/2]

QwtTextLabel * QwtPlot::footerLabel ( )

Get the footer label widget.

Returns
Footer label widget

◆ footerLabel() [2/2]

const QwtTextLabel * QwtPlot::footerLabel ( ) const

Get the footer label widget.

Returns
Footer label widget (const)

◆ getCanvasMarginsHint()

void QwtPlot::getCanvasMarginsHint ( const QwtScaleMap  maps[],
const QRectF &  canvasRect,
double &  left,
double &  top,
double &  right,
double &  bottom 
) const
virtual

Calculate the canvas margins.

Parameters
mapsQwtAxis::AxisCount maps, mapping between plot and paint device coordinates
canvasRectBounding rectangle where to paint
leftReturn parameter for the left margin
topReturn parameter for the top margin
rightReturn parameter for the right margin
bottomReturn parameter for the bottom margin

Plot items might indicate, that they need some extra space at the borders of the canvas by the QwtPlotItem::Margins flag.

updateCanvasMargins(), QwtPlotItem::getCanvasMarginHint()

◆ hostPlot()

QwtPlot * QwtPlot::hostPlot ( ) const

Get the host plot for this parasite plot.

This method returns the host plot of this parasite plot, or nullptr if this plot is not a parasite.

Returns
Pointer to the host QwtPlot
Return values
nullptrif this plot is not a parasite plot
See also
isParasitePlot()

◆ infoToItem()

QwtPlotItem * QwtPlot::infoToItem ( const QVariant &  itemInfo) const
virtual

Identify the plot item according to an item info object, that has bee generated from itemToInfo().

The default implementation simply tries to unwrap a QwtPlotItem pointer:

if ( itemInfo.canConvert<QwtPlotItem *>() )
return qvariant_cast<QwtPlotItem *>( itemInfo );
Base class for items on the plot canvas.
Definition qwt_plot_item.h:85
Parameters
itemInfoPlot item
Returns
A plot item, when successful, otherwise a nullptr pointer.
See also
itemToInfo()

◆ initParasiteAxes()

void QwtPlot::initParasiteAxes ( QwtPlot parasitePlot) const
protected

Initialize basic properties of the parasite axes.

Parameters
parasitePlotThe parasite plot to initialize

◆ insertLegend()

void QwtPlot::insertLegend ( QwtAbstractLegend legend,
QwtPlot::LegendPosition  pos = QwtPlot::RightLegend,
double  ratio = -1.0 
)

Insert a legend.

If the position legend is QwtPlot::LeftLegend or QwtPlot::RightLegend the legend will be organized in one column from top to down. Otherwise the legend items will be placed in a table with a best fit number of columns from left to right.

insertLegend() will set the plot widget as parent for the legend. The legend will be deleted in the destructor of the plot or when another legend is inserted.

Legends, that are not inserted into the layout of the plot widget need to connect to the legendDataChanged() signal. Calling updateLegend() initiates this signal for an initial update. When the application code wants to implement its own layout this also needs to be done for rendering plots to a document ( see QwtPlotRenderer ).

Parameters
legendLegend
posThe legend's position. For top/left position the number of columns will be limited to 1, otherwise it will be set to unlimited.
ratioRatio between legend and the bounding rectangle of title, canvas and axes. The legend will be shrunk if it would need more space than the given ratio. The ratio is limited to ]0.0 .. 1.0]. In case of <= 0.0 it will be reset to the default ratio. The default vertical/horizontal ratio is 0.33/0.5.
See also
legend(), QwtPlotLayout::legendPosition(), QwtPlotLayout::setLegendPosition()

◆ invTransform()

double QwtPlot::invTransform ( QwtAxisId  axisId,
double  pos 
) const

Transform the x or y coordinate of a position in the drawing region into a value.

Transform the x or y coordinate of a position in the drawing region into a value.

Parameters
axisIdAxis ID
posposition
Returns
Position as axis coordinate
Warning
The position can be an x or a y coordinate, depending on the specified axis.

◆ isAxisValid()

bool QwtPlot::isAxisValid ( QwtAxisId  axisId) const

Checks if an axis is valid.

Parameters
axisIdaxis ID
Returns
true if the specified axis exists, otherwise false
Note
This method is equivalent to QwtAxis::isValid( axisId ) and simply checks if axisId is one of the values of QwtAxis::Position. It is a placeholder for future releases, where it will be possible to have a customizable number of axes ( multiaxes branch ) at each side.

◆ isAxisVisible()

bool QwtPlot::isAxisVisible ( QwtAxisId  axisId) const

Return whether the specified axis is visible.

Parameters
axisIdAxis ID
Returns
true if the axis is visible

◆ isEnableScaleBuildinActions()

bool QwtPlot::isEnableScaleBuildinActions ( ) const

Check if built-in axis event actions are enabled.

Returns
true if enabled

◆ isHostPlot()

bool QwtPlot::isHostPlot ( ) const

Check if this plot is a host plot.

This method returns true if this plot has one or more parasite plots.

A plot is only considered a host if it holds parasite plots.

Note
A plot cannot be both a parasite and a host at the same time, meaning a host itself is not allowed to be parasitic on another plot.
Returns
true if this plot has parasite plots
false if this plot has no parasite plots
See also
isParasitePlot(), parasitePlots()

◆ isParasitePlot()

bool QwtPlot::isParasitePlot ( ) const

Check if this plot is a parasite plot.

This method returns true if this plot is a parasite of another plot.

Returns
true if this plot is a parasite plot
false if this plot is not a parasite plot
See also
isHostPlot(), hostPlot()

◆ isParasiteShareAxis()

bool QwtPlot::isParasiteShareAxis ( QwtAxisId  axisId) const

Query whether the parasite axis shares the host's specified axis.

Parameters
axisIdThe axis ID to query
Returns
true if the current parasite axis shares the corresponding host axis; false otherwise
See also
setParasiteShareAxis

◆ isTopParasitePlot()

bool QwtPlot::isTopParasitePlot ( ) const

Whether this is the topmost parasite plot; the topmost parasite's axes are at the outermost layer and are typically updated last.

Returns
true if this is the topmost parasite plot

◆ itemAttached

void QwtPlot::itemAttached ( QwtPlotItem plotItem,
bool  on 
)
signal

A signal indicating that an item has been attached/detached.

Parameters
plotItemPlot item
onAttached/Detached

◆ itemToInfo()

QVariant QwtPlot::itemToInfo ( QwtPlotItem plotItem) const
virtual

Build an information, that can be used to identify a plot item on the legend.

The default implementation simply wraps the plot item into a QVariant object. When overloading itemToInfo() usually infoToItem() needs to reimplemeted too.

Parameters
plotItemPlot item
Returns
Plot item embedded in a QVariant
See also
infoToItem()

◆ legend() [1/2]

QwtAbstractLegend * QwtPlot::legend ( )

Get the plot's legend.

Returns
The plot's legend
See also
insertLegend()

◆ legend() [2/2]

const QwtAbstractLegend * QwtPlot::legend ( ) const

Get the plot's legend.

Returns
The plot's legend (const)
See also
insertLegend()

◆ legendDataChanged

void QwtPlot::legendDataChanged ( const QVariant &  itemInfo,
const QList< QwtLegendData > &  data 
)
signal

A signal with the attributes how to update the legend entries for a plot item.

Parameters
itemInfoInfo about a plot item, built from itemToInfo()
dataAttributes of the entries (usually <= 1) for the plot item.
See also
itemToInfo(), infoToItem(), QwtAbstractLegend::updateLegend()

◆ nextColorForItem()

QColor QwtPlot::nextColorForItem ( int  rtti)

Get the next auto-assigned color for a plot item type.

Returns the next color from the color cycle for the given rtti type. Each rtti type maintains an independent counter, so curves and bar charts each start from the first palette color.

Parameters
rttiThe rtti value of the plot item (e.g. QwtPlotItem::Rtti_PlotCurve)
Returns
Next color from the cycle
See also
colorCycle(), QwtPlotItem::rtti()

◆ panAxis()

void QwtPlot::panAxis ( QwtAxisId  axisId,
int  deltaPixels 
)

Pan the specified axis by a given number of pixels.

Parameters
axisIdAxis ID (QwtPlot::xBottom, QwtPlot::yLeft, etc.)
deltaPixelsNumber of pixels to move

Positive values move right/down, negative values move left/up. For logarithmic axes, coordinate transformations are handled automatically.

Note
This function does not trigger a repaint; the caller must manually call replot

◆ panCanvas()

void QwtPlot::panCanvas ( const QPoint &  offset)

Pan the entire canvas by a pixel offset.

Parameters
offsetPixel offset

This method translates all axes (whether enabled or not) by the specified pixel offset, achieving a synchronized panning effect for the entire canvas. Horizontal direction: positive moves right, negative moves left Vertical direction: positive moves down, negative moves up

Note
This function does not trigger a repaint; the caller must manually call replot

◆ parasitePlotAt()

QwtPlot * QwtPlot::parasitePlotAt ( int  index) const

Get the nth parasite plot.

Parameters
indexIndex
Returns
nullptr if out of range or if this plot is a parasite plot

◆ parasitePlotAttached

void QwtPlot::parasitePlotAttached ( QwtPlot parasitePlot,
bool  on 
)
signal

Identify the relationship between the parasitic plot and its host plot.

Parameters
parasitePlotParasite plot
onWhen a parasitic plot is added, on = true. When the parasitic plot is removed, on = false.
Note
This signal is emitted only by the host plot.

◆ parasitePlotCount()

int QwtPlot::parasitePlotCount ( ) const

Get the number of parasite plots.

Returns
0 if this plot is a parasite plot, otherwise the count of parasite plots

◆ parasitePlotIndex()

int QwtPlot::parasitePlotIndex ( QwtPlot parasite) const

Parasite plot index (level)

The parasite level is determined by the order of addition. The first parasite added is at level 0, the second at level 1, and so on. The higher the level, the closer the axis is to the plot boundary.

Parameters
parasiteParasite plot
Returns
-1 if invalid index
Note
If the passed parasite is not a parasite of this plot, returns -1
This function is only valid for host plots; calling it on a parasite plot also returns -1

◆ parasitePlots()

QList< QwtPlot * > QwtPlot::parasitePlots ( ) const

Get all parasite plots associated with this host plot.

This method returns a list of all parasite plots that are associated with this host plot.

Returns
List of parasite QwtPlot pointers
// Get all parasite plots
const QList<QwtPlot*> parasites = hostPlot->parasitePlots();
// Perform an operation on all parasite plots
for (QwtPlot* parasite : parasites) {
parasite->replot();
}
Definition qwt_raster_data.h:38
QList< QwtPlot * > parasitePlots() const
Get all parasite plots associated with this host plot.
Definition qwt_plot.cpp:1603
See also
addParasitePlot(), removeParasitePlot()

◆ plotId()

QString QwtPlot::plotId ( ) const

Plot ID.

The plot ID is provided to enable a Figure to identify individual plots during persistence.

For example, after saving a Figure in XML format, it is necessary to know which plots have established axis synchronization signals with which other plots, and which plot boundaries have been aligned. These tasks require locating specific plots, which can be achieved using the plot ID.

Returns
A unique UUID

◆ plotLayout() [1/2]

QwtPlotLayout * QwtPlot::plotLayout ( )

Get the plot's layout.

Returns
The plot's layout

◆ plotLayout() [2/2]

const QwtPlotLayout * QwtPlot::plotLayout ( ) const

Get the plot's layout.

Returns
The plot's layout (const)

◆ plotList()

QList< QwtPlot * > QwtPlot::plotList ( bool  descending = false) const

Return all plots, including the host plot.

descending=false: ascending order, host plot first, lower levels first. descending=true: descending order, host at the end.

Parameters
descendingSort order
Returns
Ordered list of all plots

◆ removeParasitePlot()

void QwtPlot::removeParasitePlot ( QwtPlot parasite)

Remove a parasite plot from this host plot.

This method removes the parasite relationship between this host plot and the specified plot.

Parameters
parasitePointer to the parasite QwtPlot to remove
Note
This method does not delete the parasite plot, it only removes the relationship.
// Remove a parasite plot
// Now the plot is independent and can be used elsewhere
void removeParasitePlot(QwtPlot *parasite)
Remove a parasite plot from this host plot.
Definition qwt_plot.cpp:1572
See also
addParasitePlot(), parasitePlots()

◆ replot

void QwtPlot::replot ( )
virtualslot

Redraw the plot.

If the autoReplot option is not set (which is the default) or if any curves are attached to raw data, the plot has to be refreshed explicitly in order to make changes visible.

See also
updateAxes(), setAutoReplot()

◆ rescaleAxes()

void QwtPlot::rescaleAxes ( bool  onlyVisibleItems = true,
double  marginPercent = 0.05,
QwtAxisId  xAxis = QwtPlot::xBottom,
QwtAxisId  yAxis = QwtPlot::yLeft 
)

Rescale axes to fit all data items.

This function automatically adjusts the axis ranges to fit all visible data items in the plot. It calculates the bounding rectangle of all plot items and sets appropriate axis scales with optional margins.

Parameters
onlyVisibleItemsIf true, only visible items are considered
marginPercentPercentage of margin to add around the data range
xAxisThe x-axis to rescale (default: QwtPlot::xBottom)
yAxisThe y-axis to rescale (default: QwtPlot::yLeft)

Basic usage:

// Rescale to fit all visible items with default 5% margin
void rescaleAxes(bool onlyVisibleItems=true, double marginPercent=0.05, QwtAxisId xAxis=QwtPlot::xBottom, QwtAxisId yAxis=QwtPlot::yLeft)
Rescale axes to fit all data items.
Definition qwt_plot.cpp:1795

Custom margin:

// Rescale with 10% margin around data
rescaleAxes(true, 0.1);
See also
QwtPlotItem::boundingRect()
QwtPlot::setAxisScale()

◆ resizeEvent()

void QwtPlot::resizeEvent ( QResizeEvent *  e)
overrideprotectedvirtual

Resize and update internal layout.

Parameters
eResize event

◆ setAutoReplot()

void QwtPlot::setAutoReplot ( bool  tf = true)

Set or reset the autoReplot option.

If the autoReplot option is set, the plot will be updated implicitly by manipulating member functions. Since this may be time-consuming, it is recommended to leave this option switched off and call replot() explicitly if necessary.

The autoReplot option is set to false by default, which means that the user has to call replot() in order to make changes visible.

Parameters
tftrue or false. Defaults to true.
See also
replot()

◆ setAxisAutoScale()

void QwtPlot::setAxisAutoScale ( QwtAxisId  axisId,
bool  on = true 
)

Enable autoscaling for a specified axis.

This member function is used to switch back to autoscaling mode after a fixed scale has been set. Autoscaling is enabled by default.

Parameters
axisIdAxis ID
onOn/Off
See also
setAxisScale(), setAxisScaleDiv(), updateAxes()
Note
The autoscaling flag has no effect until updateAxes() is executed ( called by replot() ).

◆ setAxisFont()

void QwtPlot::setAxisFont ( QwtAxisId  axisId,
const QFont &  font 
)

Change the font of an axis.

Parameters
axisIdAxis ID
fontFont
Warning
This function changes the font of the tick labels, not of the axis title.

◆ setAxisLabelAlignment()

void QwtPlot::setAxisLabelAlignment ( QwtAxisId  axisId,
Qt::Alignment  alignment 
)

Change the alignment of the tick labels.

Parameters
axisIdAxis ID
alignmentOr'd Qt::AlignmentFlags see <qnamespace.h>
See also
QwtScaleDraw::setLabelAlignment()

◆ setAxisLabelRotation()

void QwtPlot::setAxisLabelRotation ( QwtAxisId  axisId,
double  rotation 
)

Rotate all tick labels.

Parameters
axisIdAxis ID
rotationAngle in degrees. When changing the label rotation, the label alignment might be adjusted too.
See also
QwtScaleDraw::setLabelRotation(), setAxisLabelAlignment()

◆ setAxisMaxMajor()

void QwtPlot::setAxisMaxMajor ( QwtAxisId  axisId,
int  maxMajor 
)

Set the maximum number of major scale intervals for a specified axis.

Parameters
axisIdAxis ID
maxMajorMaximum number of major steps
See also
axisMaxMajor()

◆ setAxisMaxMinor()

void QwtPlot::setAxisMaxMinor ( QwtAxisId  axisId,
int  maxMinor 
)

Set the maximum number of minor scale intervals for a specified axis.

Parameters
axisIdAxis ID
maxMinorMaximum number of minor steps
See also
axisMaxMinor()

◆ setAxisScale()

void QwtPlot::setAxisScale ( QwtAxisId  axisId,
double  min,
double  max,
double  stepSize = 0 
)

Disable autoscaling and specify a fixed scale for a selected axis.

In updateAxes() the scale engine calculates a scale division from the specified parameters, that will be assigned to the scale widget. So updates of the scale widget usually happen delayed with the next replot.

Parameters
axisIdAxis ID
minMinimum of the scale
maxMaximum of the scale
stepSizeMajor step size. If step == 0, the step size is calculated automatically using the maxMajor setting.
See also
setAxisMaxMajor(), setAxisAutoScale(), axisStepSize(), QwtScaleEngine::divideScale()

◆ setAxisScaleDiv()

void QwtPlot::setAxisScaleDiv ( QwtAxisId  axisId,
const QwtScaleDiv scaleDiv 
)

Disable autoscaling and specify a fixed scale for a selected axis.

The scale division will be stored locally only until the next call of updateAxes(). So updates of the scale widget usually happen delayed with the next replot.

Parameters
axisIdAxis ID
scaleDivScale division
See also
setAxisScale(), setAxisAutoScale()

◆ setAxisScaleDraw()

void QwtPlot::setAxisScaleDraw ( QwtAxisId  axisId,
QwtScaleDraw scaleDraw 
)

Set a scale draw.

By passing scaleDraw it is possible to extend QwtScaleDraw functionality and let it take place in QwtPlot. Please note that scaleDraw has to be created with new and will be deleted by the corresponding QwtScale member ( like a child object ).

Parameters
axisIdAxis ID
scaleDrawObject responsible for drawing scales.
See also
QwtScaleDraw, QwtScaleWidget
Warning
The attributes of scaleDraw will be overwritten by those of the previous QwtScaleDraw.

◆ setAxisScaleEngine()

void QwtPlot::setAxisScaleEngine ( QwtAxisId  axisId,
QwtScaleEngine scaleEngine 
)

Change the scale engine for an axis.

Parameters
axisIdAxis ID
scaleEngineScale engine
Note
The old scale engine will be deleted
See also
axisScaleEngine()

◆ setAxisTickDirection()

void QwtPlot::setAxisTickDirection ( QwtAxisId  axisId,
TickDirection  direction 
)

Set the tick direction for an axis.

When set to TickInside, the tick marks are drawn from the canvas edge toward the interior. The outside tick component is disabled on the QwtScaleWidget, and inside ticks are drawn in drawCanvas.

Parameters
axisIdAxis identifier
directionTick direction (TickOutside or TickInside)
See also
axisTickDirection()

◆ setAxisTitle() [1/2]

void QwtPlot::setAxisTitle ( QwtAxisId  axisId,
const QString &  title 
)

Change the title of a specified axis.

Parameters
axisIdAxis ID
titleaxis title

◆ setAxisTitle() [2/2]

void QwtPlot::setAxisTitle ( QwtAxisId  axisId,
const QwtText title 
)

Change the title of a specified axis.

Parameters
axisIdAxis ID
titleAxis title

◆ setAxisToDateTime()

void QwtPlot::setAxisToDateTime ( QwtAxisId  axisId,
Qt::TimeSpec  timeSpec = Qt::LocalTime 
)

Set the specified axis to date-time scale.

This method configures the axis to display date-time formatted labels using QwtDateScaleEngine and QwtDateScaleDraw. Data should be provided as milliseconds since epoch (QDateTime::toMSecsSinceEpoch).

Parameters
axisIdAxis identifier, e.g., QwtPlot::xBottom, QwtPlot::yLeft
timeSpecTime zone specification, defaults to Qt::LocalTime
// Set X axis to UTC date-time scale
plot->setAxisToDateTime(QwtPlot::xBottom, Qt::UTC);
QDateTime start = QDateTime::currentDateTime().addSecs(-3600);
QVector<double> timestamps, values;
for (int i = 0; i < 60; ++i) {
timestamps << start.addSecs(i * 60).toMSecsSinceEpoch(); // per minute
values << 1.0 + qAbs(qSin(i * 0.2)) * 100;
}
QwtPlotCurve *curve = new QwtPlotCurve("Data");
curve->setSamples(timestamps, values);
curve->attach(plot);
plot->setAxisScale(QwtPlot::xBottom, timestamps.first(), timestamps.last());
plot->updateAxes();
plot->replot();
Definition qwt_clipper.h:41
void setSamples(const double *xData, const double *yData, int size)
Set data by copying x- and y-values from specified memory blocks (double)
Definition qwt_plot_curve.cpp:1227
See also
setAxisToLogScale(), setAxisToLinearScale(), QwtDateScaleEngine, QDateTime::toMSecsSinceEpoch()

◆ setAxisToLinearScale()

void QwtPlot::setAxisToLinearScale ( QwtAxisId  axisId)

Restore the specified axis to linear scale.

This method replaces the current scale engine and draw with default linear versions. Useful to revert from logarithmic or date-time scales.

Parameters
axisIdAxis identifier, e.g., QwtPlot::xBottom, QwtPlot::yLeft
Note
Previous scale engine and draw are deleted automatically.
// Switch back to linear scale after using log scale
plot->setAxisToLinearScale(QwtPlot::yLeft);
plot->updateAxes();
plot->replot();
See also
setAxisToLogScale(), setAxisToDateTime(), QwtLinearScaleEngine

◆ setAxisToLogScale()

void QwtPlot::setAxisToLogScale ( QwtAxisId  axisId)

Set the specified axis to logarithmic scale.

This method replaces the current scale engine of the axis with QwtLogScaleEngine, enabling logarithmic scaling. All data values must be greater than zero.

Parameters
axisIdAxis identifier, e.g., QwtPlot::xBottom, QwtPlot::yLeft
Note
This method deletes the previous scale engine automatically. Data <= 0 will cause undefined behavior.
// Set Y axis to logarithmic scale
plot->setAxisToLogScale(QwtPlot::yLeft);
QVector<double> x = {1, 10, 100, 1000};
QVector<double> y = {1, 100, 10000, 1e6};
QwtPlotCurve *curve = new QwtPlotCurve();
curve->setSamples(x, y);
curve->attach(plot);
plot->replot();
See also
setAxisToDateTime(), setAxisToLinearScale(), QwtLogScaleEngine

◆ setAxisVisible()

void QwtPlot::setAxisVisible ( QwtAxisId  axisId,
bool  on = true 
)

Hide or show a specified axis.

Curves, markers and other items can be attached to hidden axes, and transformation of screen coordinates into values works as normal.

Only QwtAxis::XBottom and QwtAxis::YLeft are enabled by default.

Parameters
axisIdAxis ID
ontrue (visible) or false (hidden)

◆ setBackgroundColor()

void QwtPlot::setBackgroundColor ( const QColor &  c)

Set background color.

Parameters
cColor

◆ setCanvas()

void QwtPlot::setCanvas ( QWidget *  canvas)

Set the drawing canvas of the plot widget.

QwtPlot invokes methods of the canvas as meta methods ( see QMetaObject ). In opposite to using conventional C++ techniques like virtual methods they allow to use canvas implementations that are derived from QWidget or QGLWidget.

The following meta methods could be implemented:

  • replot() When the canvas doesn't offer a replot method, QwtPlot calls update() instead.
  • borderPath() The border path is necessary to clip the content of the canvas When the canvas doesn't have any special border ( f.e rounded corners ) it is o.k. not to implement this method.

The default canvas is a QwtPlotCanvas

Parameters
canvasCanvas Widget
See also
canvas()

◆ setCanvasBackground()

void QwtPlot::setCanvasBackground ( const QBrush &  brush)

Change the background of the plotting area.

Sets brush to QPalette::Window of all color groups of the palette of the canvas. Using canvas()->setPalette() is a more powerful way to set these colors.

Parameters
brushNew background brush
See also
canvasBackground()

◆ setColorCycle()

void QwtPlot::setColorCycle ( const QwtColorCycle colorCycle)

Set the color cycle used for automatic item coloring.

When plot items (curves, bar charts, etc.) are attached without a user-specified pen or brush, they automatically receive a color from this color cycle.

Parameters
colorCycleColor cycle object
See also
colorCycle(), nextColorForItem()

◆ setEnableScaleBuildinActions()

void QwtPlot::setEnableScaleBuildinActions ( bool  on)

Enable or disable built-in axis event actions.

Axis events are built-in event actions for axes, primarily including click-to-move-axis, mouse wheel zoom, etc.

Parameters
onEnable state

◆ setFooter() [1/2]

void QwtPlot::setFooter ( const QString &  text)

Change the footer text.

Parameters
[in]textNew text of the footer as a string

◆ setFooter() [2/2]

void QwtPlot::setFooter ( const QwtText text)

Change the footer text.

Parameters
[in]textNew text of the footer as a QwtText

◆ setParasiteShareAxis()

void QwtPlot::setParasiteShareAxis ( QwtAxisId  axisId,
bool  isShare = true 
)

Set whether the parasite axis shares the host's specified axis, only valid for parasite axes.

Parameters
axisIdThe axis ID to share (e.g., QwtAxis::YLeft)
isShareWhether to enable sharing
See also
isParasiteShareAxis

◆ setPlotId()

void QwtPlot::setPlotId ( const QString &  id)

set the plot id.

Parameters
id

◆ setPlotLayout()

void QwtPlot::setPlotLayout ( QwtPlotLayout layout)

Assign a new plot layout.

Parameters
layoutLayout()
See also
plotLayout()

◆ setTitle() [1/2]

void QwtPlot::setTitle ( const QString &  title)

Change the plot's title.

Parameters
[in]titleNew title as a string

◆ setTitle() [2/2]

void QwtPlot::setTitle ( const QwtText title)

Change the plot's title.

Parameters
[in]titleNew title as a QwtText

◆ setupScaleEventDispatcher()

void QwtPlot::setupScaleEventDispatcher ( QwtPlotScaleEventDispatcher dispatcher)

Install the axis event dispatcher.

Parameters
dispatcherThe event dispatcher to install

◆ sizeHint()

QSize QwtPlot::sizeHint ( ) const
overridevirtual
Returns
Size hint for the plot widget
See also
minimumSizeHint()

◆ syncAxis()

void QwtPlot::syncAxis ( QwtAxisId  axis,
const QwtPlot plot 
)

Synchronize the axis ranges from the given plot to this plot.

Parameters
axisAxis ID
plotSource plot to sync from

◆ title()

QwtText QwtPlot::title ( ) const

Get the plot's title.

Returns
Title of the plot

◆ titleLabel() [1/2]

QwtTextLabel * QwtPlot::titleLabel ( )

Get the title label widget.

Returns
Title label widget

◆ titleLabel() [2/2]

const QwtTextLabel * QwtPlot::titleLabel ( ) const

Get the title label widget.

Returns
Title label widget (const)

◆ transform()

double QwtPlot::transform ( QwtAxisId  axisId,
double  value 
) const

Transform a value into a coordinate in the plotting region.

Parameters
axisIdAxis ID
valuevalue
Returns
X or Y coordinate in the plotting region corresponding to the value.

◆ updateAllAxisEdgeMargin()

void QwtPlot::updateAllAxisEdgeMargin ( )

Batch update edge offsets for all axis positions.

Sequentially calls updateAxisEdgeMargin(QwtAxisId) for all axis positions (YLeft, YRight, XBottom, XTop) of the current plot instance, automatically synchronizing edgeMargin and margin between the host and all parasite axes, ensuring no overlap between layers and proper alignment of plot areas in multi-axis scenarios.

Typical invocation timing:

  • After a parasite plot is mounted or removed;
  • After property changes that affect dimensions, such as axis visibility, label fonts, or tick lengths;
  • When axis label width/height changes significantly due to host or parasite axis data range changes.
    See also
    updateAxisEdgeMargin(QwtAxisId)

◆ updateAxes()

void QwtPlot::updateAxes ( )

Rebuild the axes scales.

In case of autoscaling the boundaries of a scale are calculated from the bounding rectangles of all plot items, having the QwtPlotItem::AutoScale flag enabled ( QwtScaleEngine::autoScale() ). Then a scale division is calculated ( QwtScaleEngine::divideScale() ) and assigned to scale widget.

When the scale boundaries have been assigned with setAxisScale() a scale division is calculated ( QwtScaleEngine::divideScale() ) for this interval and assigned to the scale widget.

When the scale has been set explicitly by setAxisScaleDiv() the locally stored scale division gets assigned to the scale widget.

The scale widget indicates modifications by emitting a QwtScaleWidget::scaleDivChanged() signal.

updateAxes() is usually called by replot().

See also
setAxisAutoScale(), setAxisScale(), setAxisScaleDiv(), replot(), QwtPlotItem::boundingRect()

◆ updateAxisEdgeMargin()

void QwtPlot::updateAxisEdgeMargin ( QwtAxisId  axisId)

Recalculate and assign edgeMargin and margin for all layers (host + parasite) axes based on level order.

In the Qwt multi-axis system, a host plot can mount any number of parasite plots. Each parasite plot shares the same canvas position as the host but has its own independent axes. To avoid overlap between axis layers, two offsets need to be dynamically calculated for each axis:

  1. edgeMargin – The distance from the current axis to the canvas border, accumulated from the theoretical sizes of all axes at higher levels.
  2. margin – The distance from the current axis to the plot area, accumulated from the theoretical sizes of all axes at lower levels.

Level rules defined here:

  • The host is always at level 0 (innermost layer);
  • Parasite plots form levels 1, 2, 3... in the order they are mounted, with larger numbers being closer to the outside of the canvas.

Calculation flow:

  1. Collect the "net" rectangles of the host and all visible parasite axes (with old edgeMargin and margin stripped);
  2. For each level i:
    • margin = sum of net rectangle sizes from level 0 to i-1;
    • edgeMargin = sum of net rectangle sizes from level i+1 to the last level;
  3. Assign the new values to the corresponding axis's QwtScaleWidget;
  4. The host's margin is preserved (not overwriting values that users may have manually set).

Notes:

  • If the current axis is not visible or the parasite plot does not use QwtParasitePlotLayout, it is skipped automatically;
  • All rectangle dimensions within the function are taken as width or height based on axis direction: Y axes (YLeft/YRight) use width, X axes (XBottom/XTop) use height.
Parameters
axisIdThe axis ID to process
Note
This function only modifies geometric offsets and does not trigger layout or repaint; the caller can subsequently call hostPlot->updateLayout() if needed.
See also
QwtScaleWidget::setEdgeMargin(), QwtScaleWidget::setMargin(), QwtParasitePlotLayout::parasiteScaleRect()
Since
7.0.4

◆ updateCanvasMargins()

void QwtPlot::updateCanvasMargins ( )

Update the canvas margins.

Plot items might indicate, that they need some extra space at the borders of the canvas by the QwtPlotItem::Margins flag.

getCanvasMarginsHint(), QwtPlotItem::getCanvasMarginHint()

◆ updateItemsToScaleDiv()

void QwtPlot::updateItemsToScaleDiv ( )

Update the scale range of all plot items to match the current axis scales.

This is typically called when axes change, forcing all plot items to update their ranges.

◆ updateLayout()

void QwtPlot::updateLayout ( )
virtual

Adjust plot content to its current size.

See also
resizeEvent()

◆ updateLegend() [1/2]

void QwtPlot::updateLegend ( )

◆ updateLegend() [2/2]

void QwtPlot::updateLegend ( const QwtPlotItem plotItem)

Emit legendDataChanged() for a plot item.

Parameters
plotItemPlot item
See also
QwtPlotItem::legendData(), legendDataChanged()

◆ visibleXAxisId()

QwtAxisId QwtPlot::visibleXAxisId ( ) const

Return the currently visible X axis.

Selection policy (descending priority):

  1. Axis must be visible (isAxisVisible() == true);
  2. If both XBottom and XTop are visible, prefer XBottom;
  3. If only one X axis is visible, return it;
  4. If both are invisible, return default QwtAxis::XBottom.
Returns
Selected X axis ID

◆ visibleYAxisId()

QwtAxisId QwtPlot::visibleYAxisId ( ) const

Return the currently usable Y axis.

Selection policy (descending priority):

  1. Axis must be visible;
  2. If both YLeft and YRight are visible, prefer YLeft;
  3. If only one Y axis is visible, return it;
  4. If both are invisible, return default QwtAxis::YLeft.
Returns
Selected Y axis ID

◆ zoomAxis()

void QwtPlot::zoomAxis ( QwtAxisId  axisId,
double  factor,
const QPoint &  centerPosPixels 
)

Zoom the axis centered at the specified pixel position.

Parameters
axisIdAxis ID
factorZoom factor (>1 for zoom in, <1 for zoom out)
centerPosPixelsPixel position of the zoom center (relative to canvas)

Zoom principle:

  • Linear axes: zoom centered at the mouse position linearly
  • Logarithmic axes: zoom centered at the mouse position in the logarithmic domain
Note
This function does not trigger a repaint; the caller must manually call replot

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