Qwt Programmer's Manual

QwtPlot


NAME

Qwtplot - A 2-D plotting widget

SYNOPSIS

#include<qwt_plot.h>

INHERITED CLASSES

QFrame

DESCRIPTION

QwtPlot is a widget for plotting two-dimensional graphs. An unlimited number of data pairs can be displayed as curves in different styles and colors. A plot can have up to four axes, with each curve attached to an x- and a y axis. The scales at the axes are dimensioned automatically using an algorithm which can be configured separately for each axis. Linear and logarithmic scaling is supported. Markers of different styles can be added to the plot.

Curves and markers are identified by unique keys which are generated automatically when a curve or a marker is created. These keys are used to access the properties of the corresponding curves and markers.

A QwtPlot widget can have up to four axes which are indexed by the constants QwtPlot::yLeft, QwtPlot::yRight, QwtPlot::xTop, and QwtPlot::xBottom. Curves, markers, and the grid must be attached to an x axis and a y axis (Default: yLeft and xBottom).

USAGE

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>

      QwtPlot *myPlot;
      long curve1, curve2;                    // keys
      double x[100], y1[100], y2[100];        // x and y values

      myPlot = new QwtPlot("Two Graphs", parent, name);

      // add curves
      curve1 = myPlot->insertCurve("Graph 1");
      curve2 = myPlot->insertCurve("Graph 2");

      getSomeValues(x, y1, y2);

      // copy the data into the curves
      myPlot->setCurveData(curve1, x, y1, 100);      
      myPlot->setCurveData(curve2, x, y2, 100);

      // finally, refresh the plot
      myPlot->replot();              


PUBLIC MEMBERS

General

QwtPlot (1)
Constructor
QwtPlot (2)
Constructor
~QwtPlot
Destructor
setTitle
Change the title
setTitleFont
Specify the title font
enableOutline
Enable/disable outline drawing
setPlotBackground
Set a background color for the plotting region
setPlotBorder
Set border width for the plotting region
setOutlineStyle
Specify the outline style
setOutlinePen
Assign a pen for outline drawing
setAutoReplot
Enable automatic replot
outlineEnabled
Enable outline drawing
autoReplot
Return TRUE if automatic replot enabled
plotBackground
Return background color of the plotting region
plotBorder
Return border width of the plotting region
outlinePen
Return pen for outline drawing
outlineStyle
Return outline style
print
Print to file or printer
title
Return the title
titleFont
Return the title font
axisValid
Return TRUE if a number is a valid axis key
clear
Remove all curves and markers

Curves

insertCurve
Insert a new curve
removeCurve
Remove a curve
removeCurves
Remove all curves
setCurveData
Assign data to a curve
setCurveOptions
Specify curve
setCurvePen
Set Style options
setCurveRawData
Attach data
setCurveSplineSize
Set spline size
setCurveStyle
Set curve style
setCurveSymbol
Assign a symbol
setCurveTitle
Assign a title
setCurveXAxis
Attach an x axis
setCurveYAxis
Attach a y axis
setCurveBaseline
Set baseline value
curveKeys
Return all valid curve keys
curveOptions
Return style options
curvePen
Return pen
curveSplineSize
Return spline size
curveStyle
Return style
curveSymbol
Return symbol
curveTitle
Return title
curveXAxis
Return attached x axis
curveYAxis
Return attached y axis
curveBaseline
Return baseline value
closestCurve (1)
Find closest curve to a given location
closestCurve (2)
Find closest data point to a given location

Grid

enableGridX
Enable or disable vertical gridlines
enableGridXMin
Enable or disable minor vertical gridlines
enableGridY
Enable or disable horizontal gridlines
enableGridYMin
Enable or disable minor horizontal gridlines
setGridXAxis
Attach an x axis
setGridYAxis
Attach a y axis
setGridPen
Specify pen for all gridlines
setGridMajPen
Specify pen for major gridlines
setGridMinPen
Specify pen for minor gridlines
gridXAxis
Return attached x axis
gridYAxis
Return attached y axis
gridMinPen
Return pen for minor gridlines
gridMajPen
Return pen for major gridlines

Axes

changeAxisOptions
Change options
enableAxis
Enable/disable axis
setAxisFont
Specify font for tick labels
setAxisMargins
Specify margins
setAxisOptions
Specify options
setAxisAutoScale
Enable autoscaling
setAxisScale
Set fixed scale
setAxisTitleFont
Set Title font
setAxisMaxMinor
Set max. number of major tickmarks
setAxisMaxMajor
Set max. number of minor tickmarks
setAxisReference
Set a reference value
setAxisTitle
Assign a title
invTransform
Transform position to value
transform
Transform value to position
axisAutoScale
Return TRUE if autoscaling enabled
axisEnabled
Return TRUE if axis enabled
axisFont
Return font
axisMargins
Return margins
axisMaxMajor
Return max. number of major tickmarks
axisMaxMinor
Return max. number of minor tickmarks
axisOptions
Return options
axisReference
Return reference value
axisScale
Return scale division
axisTitle
Return title
axisTitleFont
Return the title's font

Markers

insertMarker
Insert a new marker
insertLineMarker
Insert horizontal or vertical line
removeMarker
Remove a marker
removeMarkers
Remove all markers
setMarkerFont
Specify font for the label
setMarkerLinePen
Specify pen for line drawing
setMarkerLineStyle
Specify line style
setMarkerPos
Set (x,y) position
setMarkerSymbol
Assign a symbol
setMarkerLabel
Assign a label
setMarkerLabelAlign
Specify label alignment
setMarkerLabelPen
Specify pen for label
setMarkerXPos
Change x position
setMarkerYPos
Change y position
setMarkerPen
Specify a pen for label and lines
setMarkerXAxis
Attach an x axis
setMarkerYAxis
Attach a y axis
markerKeys
Return all valid marker keys
markerFont
Return font
markerLinePen
Return line pen
markerLineStyle
Return [line style
markerPos
Return (x,y) position
markerSymbol
Return symbol
markerLabel
Return label text
markerLabelAlign
Return label alignment
markerLabelPen
Return label pen
markerXAxis
Return attached x axis
markerYAxis
Return attached y axis
closestMarker
Find closest marker to a given position

Legend

enableLegend
Enable legend
setLegendPos
Set relative position of the legend
setLegendFont
Specify font for the legend items
setLegendFrameStyle
Specify frame style of the legend
legendEnabled
Return TRUE if legend enabled
legendPos
Return legend position
legendFrameStyle
Return frame style
legendFont
Return font

SIGNALS

plotMousePressed
Mouse pressed in plotting region
plotMouseReleased
Mouse released in plotting region
plotMouseMoved
Mouse moved in plotting region
legendClicked
Legend item clicked

SLOTS

replot
Update the plot

EXAMPLES

see examples/simple_plot, examples/rate_plot and examples/bode

MEMBER FUNCTION DESCRIPTION



Constructors / Destructors


QwtPlot::QwtPlot (1)

Constructor

Syntax

QwtPlot::QwtPlot(QWidget *p, const char * name)

Parameters

QWidget *p
parent
const char *name
name

QwtPlot::QwtPlot (2)

Constructor

Syntax

QwtPlot::QwtPlot(const char *title, QWidget *parent, const char *name)

Parameters

const char *title
title text
QWidget *p
parent widget
const char *name
widget name

QwtPlot::~QwtPlot

Destructor

Syntax

QwtPlot::~QwtPlot()

Signals


QwtPlot::plotMousePressed

A signal which is emitted when the mouse is pressed in the plotting area.

Syntax

void QwtPlot::plotMousePressed(const QMouseEvent &e)

Parameters

const QMouseEvent &e
Mouse event object, event coordinates referring to the plotting area

See also

QMouseEvent in the Qt manual

QwtPlot::plotMouseMoved

A signal which is emitted when the mouse is pressed in the plotting area.

Syntax

void QwtPlot::plotMouseMoved(const QMouseEvent &e)

Parameters

const QMouseEvent &e
Mouse event object, event coordinates referring to the plotting area

See also

QMouseEvent in the Qt manual

QwtPlot::plotMouseReleased

A signal which is emitted when a mouse button has been released in the plotting area.

Syntax

void QwtPlot::plotMouseReleased(const QMouseEvent &e)

Parameters

const QMouseEvent &e
Mouse event object, event coordinates referring to the plotting area

See also

QMouseEvent in the Qt manual

QwtPlot::legendClicked

A signal which is emitted when the user has clicked on a legend item.

Syntax

void QwtPlot::legendClicked(long key)

Parameters

long key
Key of the curve corresponding to the selected legend item


General Properties


QwtPlot::autoReplot

Returns TRUE if the autoReplot option is set.

Syntax

bool QwtPlot::autoReplot()

QwtPlot::enableOutline

Enables or disables outline drawing.

Syntax

void QwtPlot::enableOutline(bool tf)

Parameters

bool tf
TRUE(enabled) or FALSE (disabled)

Description

When the outline feature is enabled, a shape will be drawn in the plotting region when the user presses or drags the mouse. It can be used to implement crosshairs, mark a selected region, etc.

Note

An outline style has to be specified. See setOutlineStyle.

See also

setOutlineStyle

Example

See examples/bode

QwtPlot::plotBorder

Returns the border width of the plotting area

Syntax

int QwtPlot::plotBorder()

QwtPlot::setAutoReplot

Set or reset the autoReplot option

Parameters

bool tf
TRUE or FALSE. Defaults to TRUE.

Return Type

void

Return Value

Description

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.

See also

replot

Syntax

void QwtPlot::setAutoReplot(bool tf)

QwtPlot::setTitle

Change the plot's title

Syntax

void QwtPlot::setTitle(const char *t)

Parameters

const char *t
new title

QwtPlot::setTitleFont

Change the title font

Syntax

void QwtPlot::setTitleFont(const QFont &f)

Parameters

const QFont &f - new title font

QwtPlot::replot

Redraw the plot

Syntax

void QwtPlot::replot()

Description

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

setAutoReplot

QwtPlot::setPlotBackground

Change the background of the plotting area

Syntax

void QwtPlot::setPlotBackground(const QColor &c)

Parameters

const QColor &c
new background color

QwtPlot::setPlotBorder

Change the border width of the plotting area

Syntax

void QwtPlot::setPlotBorder(int w)

Parameters

int w
new border width

QwtPlot::setOutlineStyle

Specify the style of the outline

Syntax

void QwtPlot::setOutlineStyle(Qwt::Shape os)

Parameters

Qwt::Shape os
Outline Style. Valid values are: Qwt::HLine, Qwt::VLine, Qwt::Cross, Qwt::Rectangle, Qwt::Ellipse

Description

The outline style determines which kind of shape is drawn in the plotting region when the user presses a mouse button or drags the mouse. Valid Styles are:
Qwt::Cross
Cross hairs are drawn across the plotting area when the user presses a mouse button. The lines intersect at the point where the mouse was pressed and move with the mouse pointer.
Qwt::HLine, Qwt::VLine
A horizontal or vertical line appears when the user presses a mouse button. This is useful for moving line markers.
Qwt::Rectangle
A rectangle is displayed when the user drags the mouse. One corner is fixed at the point where the mouse was pressed, and the opposite corner moves with the mouse pointer. This can be used for selecting regions.
Qwt::Ellipse
Similar to Qwt::Rectangle, but with an ellipse inside a bounding rectangle.

See also

enableOutline

QwtPlot::setOutlinePen

Specify a pen for the outline

Syntax

void QwtPlot::setOutlinePen(const QPen &pn)

Parameters

const QPen &pn
new pen

QwtPlot::print

Print the plot to a QPrinter

Syntax

void QwtPlot::print(QPrinter &pr, const QwtColorFilter &cfilter = NoColorFilter)

Parameters

const QPrinter pr
The printer
const QwtColorFilter &cfilter
color filter for curves and markers

Description

This function prints the contents of a QwtPlot instance to QPrinter object. The printed output is independent of the widget displayed on the screen.

Note

Example calls


	myPlot->print(printer);			 // screen colors
	myPlot->print(printer, QwtFltrDim(200)); // colors darkened
	myPlot->print(printer, QwtFltrInv());	 // colors inverted

Bugs

See also

QwtColorFilter

QwtPlot::axisValid

Return TRUE if the specified axis exists. Static member function.

Syntax

static bool QwtPlot::axisValid(int axis)

Access

protected

Parameters

int axis
axis index

QwtPlot::plotBackground

Return the background color of the plotting area

Syntax

const QColor & QwtPlot::plotBackground() const

QwtPlot::outlineEnabled

Return TRUE if the outline feature is enabled

Syntax

bool QwtPlot::outlineEnabled() const

QwtPlot::outlinePen

Return the pen used to draw outlines

Syntax

const QPen & QwtPlot::outlinePen() const

QwtPlot::outlineStyle

Return the outline style

Syntax

Qwt::Shape QwtPlot::outlineStyle()

See also

setOutlineStyle

QwtPlot::clear

Remove all curves and markers

Syntax

void QwtPlot::clear()

QwtPlot::removeCurves

Remove all curves

Syntax

void QwtPlot::removeCurves()

QwtPlot::removeMarkers

Remove all markers

Syntax

void QwtPlot::removeMarkers()

Legend Properties


QwtPlot::enableLegend

Enable or disable the legend

Syntax

void QwtPlot::enableLegend(bool tf)

Parameters

bool tf
TRUE(enabled) or FALSE(disabled)

See also

setLegendPos

QwtPlot::setLegendPos

Specify the position of the legend within the widget

Syntax

void QwtPlot::setLegendPos(int pos)

Parameters

int pos
The legend's position. Valid values are Qwt::Left, Qwt::Right, Qwt::Top, QwtBottom.

QwtPlot::setLegendFont

Change the font of the legend items

Syntax

void QwtPlot::setLegendFont(const QFont &f)

Parameters

const QFont &f
new font

QwtPlot::setLegendFrameStyle

Change the legend's frame style

Syntax

void QwtPlot::setLegendFrameStyle(int st)

Parameters

int st
Frame Style. See Qt manual on QFrame.

QwtPlot::legendFrameStyle

Return the frame style of the legend

Syntax

int QwtPlot::legendFrameStyle() const

QwtPlot::legendFont

Return the font of the legend items

Syntax

const QFont & QwtPlot::legendFont() const

Accessing and Manipulating Curves


QwtPlot::closestCurve (1)

Find the curve which is closest to a specified point in the plotting area.

Syntax

long QwtPlot::closestCurve(int xpos, int ypos, int &dist) const

Input Parameters

int xpos, int ypos
position in the plotting region

Output Parameters

int &dist
distance in points between (xpos, ypos) and the closest data point

Return Value

Key of the closest curve or 0 if no curve was found.

QwtPlot::closestCurve (2)

Find the curve which is closest to a point in the plotting area. Determines the position and index of the closest data point.

Syntax

long QwtPlot::closestCurve(int xpos, int ypos, int &dist, double &xval, double &yval, int &index) const

Input Parameters

int xpos, int ypos
coordinates of a point in the plotting region

Output Parameters

double &xval, double &yval
values of the closest point in the curve's data array
int &dist
distance in points between (xpos, ypos) and the closest data point
int &index
index of the closest point in the curve's data array

Return Value

Key of the closest curve or 0 if no curve was found.

QwtPlot::curveStyle

Return the style of the curve indexed by key

Syntax

QwtCurve::CurveStyle QwtPlot::curveStyle(long key) const

Parameters

long key
Key of the curve

See also

setCurveStyle

QwtPlot::curveSymbol

Return the symbol of the curve indexed by key

Syntax

const QwtSymbol & QwtPlot::curveSymbol(long key) const

Parameters

long key
Key of the curve

Return Value

The symbol of the specified curve. If the key is invalid, a symbol of type 'NoSymbol'.

QwtPlot::curvePen

Return the pen of the curve indexed by key

Syntax

const QPen & QwtPlot::curvePen(long key) const

Parameters

long key
Key of the curve

QwtPlot::curveOptions

Return the drawing options of the curve indexed by key

Syntax

int QwtPlot::curveOptions(long key)

Parameters

long key
Key of the curve

QwtPlot::curveSplineSize

Return the spline size of the curve indexed by key

Syntax

int QwtPlot::curveSplineSize(long key)

Parameters

long key
Key of the curve

QwtPlot::curveTitle

Return the title of the curve indexed by key

Syntax

QString QwtPlot::curveTitle(long key) const

Parameters

long key
Key of the curve

QwtPlot::curveKeys

Return an array containing the keys of all curves

Syntax

QArray<long> QwtPlot::curveKeys() const

Return Value

Array containing the keys

QwtPlot::curveXAxis

Return the index of the x axis to which a curve is mapped

Syntax

int QwtPlot::curveXAxis(long key)

Parameters

long key
Key of the curve

Return Value

x axis of the curve or -1 if the key is invalid.

QwtPlot::curveYAxis

Return the index of the y axis to which a curve is mapped

Syntax

int QwtPlot::curveYAxis(long key) const

Return Value

y axis of the curve or -1 if the key is invalid.

QwtPlot::insertCurve

Insert a new curve and return a unique key

Syntax

long QwtPlot::insertCurve(const char *title, int xAxis = xBottom, int yAxis = yLeft)

Parameters

const char *title
title of the new curve
int xAxis
x axis to be attached. Defaults to xBottom.
int yAxis
y axis to be attached. Defaults to yLeft.

Return Value

The key of the new curve or 0 if no new key could be found or if no new curve could be allocated.

QwtPlot::removeCurve

remove the curve indexed by key

Syntax

void QwtPlot::removeCurve(long key)

Parameters

long key
Key of the curve

QwtPlot::setCurvePen

Assign a pen to a curve indexed by key

Syntax

bool QwtPlot::setCurvePen(long key, const QPen &pen)

Parameters

long key
Key of the curve
QPen &pen
new pen

Return Value

True if the curve exists

QwtPlot::setCurveSymbol

Assign a symbol to a curve indexed by key

Parameters

long key, const QwtSymbol &s

Syntax

bool QwtPlot::setCurveSymbol(long key, const QwtSymbol &s)

Return Value

True if the curve exists

QwtPlot::setCurveRawData

Attach a curve to the specified arrays without copying

Syntax

bool QwtPlot::setCurveRawData(long key, double *xdat, double *ydat, int size)

Parameters

long key
Key of the curve
double *xdat, double *ydat
Pointers to x and y data
int size
size of ydat and ydat

Return Value

True if the curve exists

Description

This function does not copy the values of the specified arrays. Removing the curve will not delete the data.

Note

Don't delete dynamically allocated data while a curve is attached to them.

See also

setCurveData, QwtCurve::setRawData

QwtPlot::setCurveTitle

Syntax

bool QwtPlot::setCurveTitle(long key, const QString &s)

Parameters

long key, const char *s

Return Value

Description


QwtPlot::setCurveData

Assign x and y values to a curve.

Syntax

bool QwtPlot::setCurveData(long key, double *xdat, double *ydat, int size)

Parameters

long key
curve key
double *xdat
pointer to x values
double *ydat
pointer to y values
int size
size of xdat and ydat

Description

In opposite to setCurveRawData, this function makes a 'deep copy' of the data.

See also

setCurveRawData, QwtCurve::setData

QwtPlot::setCurveStyle

Change a curve's style

Syntax

bool QwtPlot::setCurveStyle(long key, QwtCurve::CurveStyle s, int options)

Parameters

long key
Key of the curve
QwtCurve::CurveStyle s
display style of the curve
int options
style options

Return Value

TRUE if the curve exists

See also:

setStyle for a detailed description of valid styles.

QwtPlot::setCurveOptions

Set the style options of a curve indexed by key

Syntax

bool QwtPlot::setCurveOptions(long key, int t)

Parameters

long key
The curve's key
int opt
The type of the spline

Return Value

TRUE if the specified curve exists.

See also

QwtCurve::setOptionsfor a detailed description of valid options.

QwtPlot::setCurveSplineSize

Set the number of interpolated points of a curve indexed by key

Syntax

bool QwtPlot::setCurveSplineSize(long key, int s)

Parameters

long key
key of the curve
int s
size of the spline

Return Value

True if the curve exists

QwtPlot::setCurveXAxis

Attach a curve to an x axis

Syntax

bool QwtPlot::setCurveXAxis(long key, int axis)

Parameters

long key
key of the curve
int axis
x axis to be attached

QwtPlot::setCurveYAxis

Attach a curve to an y axis

Syntax

bool QwtPlot::setCurveYAxis(long key, int axis)

Parameters

long key
key of the curve
int axis
y axis to be attached

QwtPlot::setCurveBaseline

Set the baseline for a specified curve

Syntax

void QwtPlot::setCurveBaseline(long key, double ref)

Parameters

long key
curve key
double ref
baseline offset from zero

Return Value

Description

The baseline is needed for the curve style QwtCurve::Sticks, cf. QwtCurve::setBaseline

QwtPlot::curveBaseline

Return the baseline offset for a specified curve

Syntax

double QwtPlot::curveBaseline(long key) const

Parameters

long key
curve key

Return value

Baseline offset of the specified curve, or 0 if the curve doesn't exist

See also

setCurveBaseline

Accessing and Manipulating Markers


QwtPlot::closestMarker

Find the marker which is closest to a given point.

Syntax

long QwtPlot::closestMarker(int xpos, int ypos, int &dist)

Input Parameters

int xpos, int ypos
coordinates of a point in the plotting region

Output Parameters

int &dist
Distance in points between the marker and the specified point.

Return Value

Key of the closest marker or 0 if no marker was found

QwtPlot::insertLineMarker

Syntax

long QwtPlot::insertLineMarker(const char *label, int axis)

Parameters

const char *label
Label
int axis
Axis to be attached

Return Value

New key if the marker could be inserted, 0 if not.

Description

This function is a shortcut to insert a horizontal or vertical line marker, dependent on the specified axis.

QwtPlot::insertMarker

Insert a new marker

Syntax

long QwtPlot::insertMarker(char *label, int xAxis, int yAxis)

Parameters

char *label
Label
int xAxis
X axis to be attached
int yAxis
Y axis to be attached

Syntax

long QwtPlot::insertMarker(char *label, int xAxis, int yAxis)

QwtPlot::markerKeys

Return an array containing the keys of all markers

Syntax

QArray<long> QwtPlot::markerKeys() const

QwtPlot::markerFont

Return the font of a marker

Syntax

const QFont& QwtPlot::markerFont(long key) const

Parameters

long key

QwtPlot::markerLabel

Return a marker's label

Syntax

const QString& QwtPlot::markerLabel(long key) const

Parameters

long key
Marker key

QwtPlot::markerLabelAlign

Return a marker's label alignment

Syntax

int QwtPlot::markerLabelAlign(long key) const

Parameters

long key
Marker key

QwtPlot::markerLabelPen

Return the pen of a marker's label

Syntax

const QPen& QwtPlot::markerLabelPen(long key) const

Parameters

long key
Marker key

QwtPlot::markerLinePen

Return a marker's line pen

Syntax

const QPen& QwtPlot::markerLinePen(long key) const

Parameters

long key
Marker key

QwtPlot::markerLineStyle

Return a marker's line style

Syntax

QwtMarker::lineStyle QwtPlot::markerLineStyle(long key) const

Parameters

long key
Marker key

QwtPlot::markerPos

Get the position of a marker

Syntax

void QwtPlot::markerPos(long key, double &mx, double &my ) const

Input Parameters

long key
Marker key

Output Parameters

double &mx, double &my
Marker position

QwtPlot::markerSymbol

Return a marker's symbol

Syntax

const QwtSymbol& QwtPlot::markerSymbol(long key) const

Parameters

long key
Marker key

QwtPlot::markerXAxis

Return the x axis to which a marker is attached

Syntax

int QwtPlot::markerXAxis(long key) const

Parameters

long key
Marker key

QwtPlot::markerYAxis

Return the Y axis to which a marker is attached

Syntax

int QwtPlot::markerYAxis(long key) const

Parameters

long key
Marker key

QwtPlot::removeMarker

Remove the marker indexed by key

Syntax

bool QwtPlot::removeMarker(long key)

Parameters

long key
unique key

QwtPlot::setMarkerXAxis

Attach the marker to an x axis

Syntax

bool QwtPlot::setMarkerXAxis(long key, int axis)

Return Value

True if the specified marker exists.

QwtPlot::setMarkerYAxis

Attach the marker to a Y axis

Syntax

bool QwtPlot::setMarkerYAxis(long key, int axis)

Parameters

long key
Marker key
int axis
Axis to be attached

Return Value

True if the specified marker exists

QwtPlot::setMarkerFont

Specify a font for a marker's label

Syntax

bool QwtPlot::setMarkerFont(long key, const QFont &f)

Parameters

long key
Marker key
const QFont &f
New font

Return Value

True if the specified marker exists

QwtPlot::setMarkerLinePen

Specify a pen for a marker's line

Syntax

bool QwtPlot::setMarkerLinePen(long key, const QPen &p)

Parameters

long key
Marker key
const QPen &p
New pen

Return Value

True if the marker exists

QwtPlot::setMarkerLineStyle

Specify the line style for a marker

Syntax

bool QwtPlot::setMarkerLineStyle(long key, QwtMarker::LineStyle st)

Parameters

long key
Marker key
QwtMarker::LineStyle st
Line style: QwtMarker::HLine, QwtMarker::VLine, QwtMarker::NoLine or a combination of them.

Return Value

True if the specified marker exists.

QwtPlot::setMarkerPen

Specify a pen for a marker's label.

Syntax

bool QwtPlot::setMarkerPen(long key, const QPen &p)

Parameters

long key
Marker key
const QPen &p
New pen

Return Value

True if the marker exists

QwtPlot::setMarkerPos

Change the position of a marker

Syntax

bool QwtPlot::setMarkerPos(long key, double xval, double yval)

Parameters

long key
Marker key
double xval, double yval
Position of the marker in axis coordinates.

QwtPlot::setMarkerXPos

Specify the X position of a marker

Syntax

bool QwtPlot::setMarkerXPos(long key, double val)

Parameters

long key
Marker key
double val
X position of the marker

Return Value

True if the specified marker exists.

QwtPlot::setMarkerYPos

Specify the Y position of the marker

Syntax

bool QwtPlot::setMarkerYPos(long key, double val)

Parameters

long key
Marker key
double val
Y position of the marker

Return Value

True if the specified marker exists

QwtPlot::setMarkerSymbol

Assign a symbol to a specified marker

Syntax

bool QwtPlot::setMarkerSymbol(long key, const QwtSymbol &s)

Parameters

long key
Marker key
const QwtSymbol &s
new symbol

Return Value

True if the specified marker exists

QwtPlot::setMarkerLabel

Assign a label to a marker

Syntax

bool QwtPlot::setMarkerLabel(long key, const char *txt)

Parameters

long key
Marker key
const char *txt
Label text

Return Value

True if the specified marker exists

QwtPlot::setMarkerLabelAlign

Specify the alignment of a marker's label

Syntax

bool QwtPlot::setMarkerLabelAlign(long key, int align)

Parameters

long key
Marker key
int align
Alignment: AlignLeft, AlignRight, AlignTop, AlignBottom, AlignHCenter, AlignVCenter, AlignCenter or a combination of them.

Return Value

True if the specified marker exists.

Description

The alignment determines the position of the label relative to the marker's position. The default setting is AlignCenter.

QwtPlot::setMarkerLabelPen

Specify a pen for a marker's label

Syntax

bool QwtPlot::setMarkerLabelPen(long key, const QPen &p)

Parameters

long key
New key
const QPen &p
Label pen

Return Value

True if the specified marker exists.

Members for Accessing and Manipulating Axes


QwtPlot::axisAutoScale

Return TRUE if autoscaling is enabled

Syntax

bool QwtPlot::axisAutoScale(int axis) const

Parameters

int axis
axis index

QwtPlot::axisEnabled

Return TRUE if a specified axis is enabled

Syntax

bool QwtPlot::axisEnabled(int axis) const

Parameters

int axis
axis index

QwtPlot::axisFont

Return the font of the scale labels for a specified axis

Syntax

const QFont& QwtPlot::axisFont(int axis) const

Parameters

int axis
axis index

QwtPlot::axisMargins

Determine the scale margins for a specified axis

Syntax

bool QwtPlot::axisMargins(int axis, double &mlo, double &mhi)

Input Parameters

int axis

Output Parameters

double &mlo
Margin at the lower limit
double &mhi
Margin at the upper limit

See also:

QwtAutoScale::margins

QwtPlot::axisMaxMajor

Return the maximum number of major ticks for a specified axis

Syntax

int QwtPlot::axisMaxMajor(int axis) const

Parameters

int axis
axis index

QwtPlot::axisMaxMinor

Return the maximum number of minor ticks for a specified axis

Syntax

int QwtPlot::axisMaxMinor(int axis)

Parameters

int axis
axis index

QwtPlot::axisOptions

Return the autoscaling options of a specified axis

Syntax

int QwtPlot::axisOptions(int axis)

Parameters

int axis
axis index

See also

QwtAutoScale::options

QwtPlot::axisReference

Return the reference value of an axis

Syntax

double QwtPlot::axisReference(int axis) const

Parameters

int axis
axis index

Description

The reference value is needed if the autoscaling options QwtAutoScale::Symmetric or QwtAutoScale::IncludeRef are set.

See also

QwtAutoScale, setAxisOptions

QwtPlot::axisScale

Returns the scale division of a specified axis

Syntax

const QwtScaleDiv& QwtPlot::axisScale(int axis) const

Parameters

int axis
axis index

See also

QwtScaleDiv

QwtPlot::axisTitle

Return the title of a specified axis

Syntax

const QString& QwtPlot::axisTitle(int axis) const

Parameters

int axis
axis index

QwtPlot::axisTitleFont

Return the title font of a specified axis

Syntax

const QFont& QwtPlot::axisTitleFont(int axis) const

Parameters

int axis
axis index

QwtPlot::changeAxisOptions

Change specified autoscaling options of an axis

Syntax

void QwtPlot::changeAxisOptions(int axis, int opt, bool value)

Parameters

int axis
axis index
int opt
Set of or'ed options
bool value
Value to be assigned to all the specified options (TRUE or FALSE)

See also

QwtAutoScale::changeAxisOptions

QwtPlot::enableAxis

Enable or disable a specified axis

Syntax

void QwtPlot::enableAxis(int axis, bool tf)

Parameters

int axis
axis index
bool tf
TRUE (enabled) or FALSE disabled)

Description When an axis is disabled, this only means that it is not visible on the screen. Curves, markers and can be attached to disabled axes, and transformation of screen coordinates into values works as normal. Only xBottom and yLeft are enabled by default.

QwtPlot::invTransform

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

Syntax

double QwtPlot::invTransform(int axis, int pos)

Parameters

int axis
axis index
int pos
position

Note

The position can be an x or a y coordinate, depending on the specified axis.

QwtPlot::transform

Transform a value into a coordinate in the plotting region

Syntax

int QwtPlot::transform(int axis, double value) const

Parameters

int axis
axis index
double value
value

Return value

X or y coordinate in the plotting region corresponding to the value.

QwtPlot::setAxisFont

Change the font of an axis

Syntax

void QwtPlot::setAxisFont(int axis, QFont &f)

Parameters

int axis
axis index
QFont &f
font

Note

This function changes the font of the tick labels, not of the axis title.

QwtPlot::setAxisMargins

Assign margins to a specified axis

Syntax

void QwtPlot::setAxisMargins(int axis, double mlo, double mhi)

Parameters

int axis
index of the axis
double mlo
margin at the lower end of the scale
double mhi
margin at the upper end of the scale

Note

If the scale is logarithmic, the margins are measured in decades

See also

QwtAutoScale::setMargins

QwtPlot::setAxisOptions

Reset scale options and set specified options for a specified axis

Syntax

void QwtPlot::setAxisOptions(int axis, int opt)

Parameters

int axis
axis index
int opt
set of options

See also

QwtAutoScale::setOptions

QwtPlot::setAxisAutoScale

Enable autoscaling for a specified axis

Syntax

void QwtPlot::setAxisAutoScale(int axis)

Parameters

int axis
axis index

Description

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

See also

setAxisScale

QwtPlot::setAxisScale

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

Syntax

void QwtPlot::setAxisScale(int axis, double min, double max, double step = 0)

Parameters

int axis
axis index
double min, double max
minimum and maximum of the scale
double step
Major step size. If step == 0, the step size is calculated automatically using the maxMajor setting.

See also

setAxisMaxMajor

QwtPlot::setAxisTitleFont

Change the title font of a selected axis

Syntax

void QwtPlot::setAxisTitleFont(int axis, const QFont &f)

Parameters

int axis, const QFont &f

QwtPlot::setAxisMaxMinor

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

Syntax

void QwtPlot::setAxisMaxMinor(int axis, int maxMinor)

Parameters

int axis
axis index
int maxMinor
maximum number of minor steps

See also

QwtAutoScale::setMaxMinor

QwtPlot::setAxisMaxMajor

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

Syntax

void QwtPlot::setAxisMaxMajor(int axis, int maxMajor)

Parameters

int axis
axis index
int maxMajor
maximum number of major steps

See also

setMaxMajor

QwtPlot::setAxisReference

Set a reference value for a specified axis

Syntax

void QwtPlot::setAxisReference(int axis, double value)

Parameters

int axis
axis index
double value
reference value

Description

The reference value is used by some autoscaling modes.

See also

QwtAutoScale::setReference, QwtPlot:.setAxisOptions

QwtPlot::setAxisTitle

Change the title of a specified axis

Syntax

void QwtPlot::setAxisTitle(int axis, const char *t)

Parameters

int axis
axis index
const char *t
axis title

QwtPlot::verifyXAxis

Check if an index is a valid x axis

Access

protected

Syntax

int QwtPlot::verifyXAxis(int axis) const

Parameters

int axis
axis index

Return Value

Returns its input value if the specified axis is an x axis. Returns the default x axis if not.

QwtPlot::verifyYAxis

Checks if an integer is a valid index for a y axis

Syntax

int QwtPlot::verifyYAxis(int axis) const

Access

protected

Parameters

int axis

Return Value

Returns its input value if the specified axis is an x axis. Returns the default x axis if not.

Accessing and Manipulating the Coordinate Grid


QwtPlot::enableGridX

Enable or disable vertical gridlines.

Syntax

void QwtPlot::enableGridX(bool tf = TRUE)

Parameters

bool tf
Enable (TRUE) or disable (FALSE). Defaults to TRUE.

QwtPlot::enableGridY

Enable or disable horizontal gridlines

Syntax

void QwtPlot::enableGridY(bool tf)

Parameters

bool tf
enable (TRUE) or disable (FALSE). Defaults to TRUE.

QwtPlot::enableGridXMin

Enable or disable vertical gridlines for the minor scale marks

Syntax

void QwtPlot::enableGridXMin(bool tf)

Parameters

bool tf
enable (TRUE) or disable (FALSE). Defaults to TRUE.

QwtPlot::enableGridYMin

Enable or disable horizontal gridlines for the minor scale marks.

Syntax

void QwtPlot::enableGridYMin(bool tf)

Parameters

bool tf
enable (TRUE) or disable (FALSE). Defaults to TRUE.

QwtPlot::setGridXAxis

Attach the grid to an x axis

Syntax

void QwtPlot::setGridXAxis(int axis)

Parameters

int axis
x axis to be attached

QwtPlot::setGridYAxis

Attach the grid to an y axis

Syntax

void QwtPlot::setGridYAxis(int axis)

Parameters

int axis
x axis to be attached

QwtPlot::setGridPen

Change the grid's pens for major and minor gridlines

Syntax

void QwtPlot::setGridPen(const QPen &p)

Parameters

const QPen &p
new pen

QwtPlot::setGridMinPen

Change the pen for the minor gridlines

Syntax

void QwtPlot::setGridMinPen(const QPen &p)

Parameters

const QPen &p
new pen

QwtPlot::setGridMajPen

Change the pen for the major gridlines

Syntax

void QwtPlot::setGridMajPen(const QPen &p)

Parameters

const QPen &p
new pen

Qwt Widget Library 01/02/98