class QXYSeries#

The QXYSeries class is a base class for line, spline, and scatter series. More

Inheritance diagram of PySide6.QtGraphs.QXYSeries

Inherited by: QScatterSeries, QLineSeries, QSplineSeries

Synopsis#

Properties#

Methods#

Virtual methods#

Signals#

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description#

QXYSeries supports displaying best fit line on a chart. Best fit line is a line through a chart that expresses the relationship between points.

class PointConfiguration#

This enum value describes the particular configuration of a point.

Constant

Description

QXYSeries.PointConfiguration.Color

This enum value can be used to change a point’s color. If used together with setPointConfiguration , the configuration’s value should be a valid QColor.

QXYSeries.PointConfiguration.Size

This enum value can be used to change a point’s size. If used together with setPointConfiguration , the configuration’s value should be a number, such as qreal or int.

QXYSeries.PointConfiguration.Visibility

This enum value can be used to hide or show the point. If used together with setPointConfiguration , the configuration’s value should be boolean.

QXYSeries.PointConfiguration.LabelVisibility

This enum value can be used to hide or show the label of the point. If used together with setPointConfiguration , the configuration’s value should be boolean.

QXYSeries.PointConfiguration.LabelFormat

This enum value can be used to set custom label text per-point. If used together with setPointConfiguration , the configuration’s value should be a string.

Note

If an empty string is set as the LabelFormat, it will be ignored, and the series pointLabelsFormat will be used.

Note

Properties can be used directly when from __feature__ import true_property is used or via accessor functions otherwise.

property bestFitLineColorᅟ: QColor#

This property holds The color of best fit line..

Access functions:
property bestFitLineVisibleᅟ: bool#

This property holds The visibility of the best fit line..

This property is false by default.

Access functions:
property colorᅟ: QColor#

This property holds The color of the series..

This is the line (pen) color in case of QLineSeries or QSplineSeries and the fill (brush) color in case of QScatterSeries or QAreaSeries .

See also

pen() brush()

Access functions:
property pointLabelsClippingᅟ: bool#

This property holds The clipping for data point labels..

This property is true by default. The labels on the edge of the plot area are cut when clipping is enabled.

Access functions:
property pointLabelsColorᅟ: QColor#

This property holds The color used for data point labels. By default, the color is the color of the brush defined in theme for labels..

Access functions:
property pointLabelsFontᅟ: QFont#

This property holds The font used for data point labels..

Access functions:
property pointLabelsFormatᅟ: str#

This property holds The format used for showing labels with data points..

QXYSeries supports the following format tags:

@index

The index in the series of the data point. [since 6.5]

@xPoint

The x-coordinate of the data point.

@yPoint

The y-coordinate of the data point.

For example, the following usage of the format tags would produce labels that display the data point shown inside brackets separated by a comma (x, y):

series->setPointLabelsFormat("@index: (@xPoint, @yPoint)");

By default, the labels’ format is set to @xPoint, @yPoint. The labels are shown on the plot area, and the labels on the edge of the plot area are cut. If the points are close to each other, the labels may overlap.

Access functions:
property pointLabelsVisibleᅟ: bool#

This property holds The visibility of data point labels..

This property is false by default.

Access functions:
property pointsVisibleᅟ: bool#

This property holds Whether the data points are visible and should be drawn..

Access functions:
property selectedColorᅟ: QColor#

This property holds The color of the selected points..

This is the fill (brush) color of points marked as selected. If not specified, value of color is used as default.

See also

color

Access functions:
append(points)#
Parameters:

points – .list of QPointF

This is an overloaded function.

Adds the list of data points specified by points to the series.

append(point)
Parameters:

pointQPointF

This is an overloaded function.

Adds the data point point to the series.

append(x, y)
Parameters:
  • x – float

  • y – float

Adds the data point with the coordinates x and y to the series.

at(index)#
Parameters:

index – int

Return type:

QPointF

Returns the data point at the position specified by index in the internal series of points.

bestFitLineColor()#
Return type:

QColor

Getter of property bestFitLineColorᅟ .

bestFitLineColorChanged(color)#
Parameters:

colorQColor

This signal is emitted when the color used for the best fit line changes to color.

Notification signal of property bestFitLineColorᅟ .

bestFitLineEquation(ok)#
Parameters:

ok – bool

Return type:

.std.pairqreal,qreal

Returns a pair of numbers where the first number is a slope factor and the second number is intercept of a linear function for a best fit line.

Those factors are calculated using Least Squares Method based on points passed to the series.

Parameter ok is used to report a failure by setting its value to false and to report a success by setting its value to true.

bestFitLinePen()#
Return type:

QPen

bestFitLinePenChanged(pen)#
Parameters:

penQPen

bestFitLineVisibilityChanged(visible)#
Parameters:

visible – bool

This signal is emitted when the visibility of the best fit line changes to visible.

Notification signal of property bestFitLineVisibleᅟ .

bestFitLineVisible()#
Return type:

bool

Getter of property bestFitLineVisibleᅟ .

brush()#
Return type:

QBrush

Returns the brush used to fill the data points for the series.

See also

setBrush()

clear()#

Removes all points from the series.

See also

pointsRemoved()

clearPointConfiguration(index)#
Parameters:

index – int

Removes the configuration of a point located at index and restores the default look derived from the series’ settings.

Note

It doesn’t affect the configuration of other points.

clearPointConfiguration(index, key)
Parameters:
  • index – int

  • keyPointConfiguration

Removes the configuration property identified by key from the point at index and restores the default look derived from the series’ settings.

Removes the configuration type, such as color or size, specified by key from the point at index with configuration customizations, allowing that configuration property to be rendered as the default specified in the series’ properties.

Note

It doesn’t affect the configuration of other points.

clearPointsConfiguration()#

Removes the configuration of all points in the series and restores the default look derived from the series’ settings.

clearPointsConfiguration(key)
Parameters:

keyPointConfiguration

Removes the configuration property identified by key from all points and restores the default look derived from the series’ settings.

Removes the configuration type, such as color or size, specified by key from all points with configuration customizations, allowing that configuration property to be rendered as the default specified in the series properties.

clicked(point)#
Parameters:

pointQPointF

This signal is emitted when the user triggers a mouse event by clicking the point point in the chart.

color()#
Return type:

QColor

See also

setColor()

Getter of property colorᅟ .

colorBy(sourceData[, gradient=QLinearGradient()])#
Parameters:

Sets the points’ color according to a passed list of values. Values from sourceData are sorted and mapped to the gradient.

If the series has a QColorAxis attached, then a gradient from the axis is going to be used.

colorChanged(color)#
Parameters:

colorQColor

This signal is emitted when the line (pen) color changes to color.

Notification signal of property colorᅟ .

count()#
Return type:

int

Returns the number of data points in a series.

deselectAllPoints()#

Deselects all points in the series.

deselectPoint(index)#
Parameters:

index – int

Deselects point at given index.

deselectPoints(indexes)#
Parameters:

indexes – .list of int

Marks multiple points passed in a indexes list as deselected.

doubleClicked(point)#
Parameters:

pointQPointF

This signal is emitted when the user double-clicks the data point point in the chart. The point is the point where the first press was triggered.

hovered(point, state)#
Parameters:

This signal is emitted when a mouse is hovered over the point point in the chart. When the mouse moves over the point, state turns true, and when the mouse moves away again, it turns false.

insert(index, point)#
Parameters:

Inserts the data point point in the series at the position specified by index.

See also

pointAdded()

isPointSelected(index)#
Parameters:

index – int

Return type:

bool

Returns true if point at given index is among selected points and false otherwise.

Note

Selected points are drawn using the selected color if it was specified.

lightMarker()#
Return type:

QImage

Gets the image used for drawing markers on each point of the series.

The default value is QImage(), meaning no light marker will be painted.

The light markers visualize the data points of this series and as such are an alternative to setPointsVisible (true). Both features can be enabled independently from each other.

Unlike the elements of QScatterSeries the light markers are not represented by QGraphicsItem, but are just painted (no objects created). However, the mouse-event-signals of QXYSeries behave the same way, meaning that you’ll get the exact domain value of the point if you click/press/hover the light marker. You’ll still get the in between domain value if you click on the line. The light markers are above the line in terms of painting as well as events.

See also

setLightMarker()

lightMarkerChanged(lightMarker)#
Parameters:

lightMarkerQImage

This signal is emitted when the light marker image changes to lightMarker.

See also

setLightMarker()

markerSize()#
Return type:

float

Gets the size of the marker used to render points in the series.

The default size depends on the specific QXYSeries type. QScatterSeries has a default of 15.0 QLineSeries has a default of the series pen size * 1.5

See also

setMarkerSize() markerSize

markerSizeChanged(size)#
Parameters:

size – float

This signal is emitted when the marker size changes to size.

pen()#
Return type:

QPen

Returns the pen used to draw the outline of the data points for the series.

See also

setPen()

penChanged(pen)#
Parameters:

penQPen

This signal is emitted when the pen changes to pen.

pointAdded(index)#
Parameters:

index – int

This signal is emitted when a point is added at the position specified by index.

See also

append() insert()

pointConfiguration(index)#
Parameters:

index – int

Return type:

Dictionary with keys of type .QXYSeries.PointConfiguration and values of type QVariant.

Returns a map representing the configuration of a point at index.

With points configuration you can change various aspects of each point’s look.

pointLabelsClipping()#
Return type:

bool

Getter of property pointLabelsClippingᅟ .

pointLabelsClippingChanged(clipping)#
Parameters:

clipping – bool

This signal is emitted when the clipping of the data point labels changes to clipping.

Notification signal of property pointLabelsClippingᅟ .

pointLabelsColor()#
Return type:

QColor

Getter of property pointLabelsColorᅟ .

pointLabelsColorChanged(color)#
Parameters:

colorQColor

This signal is emitted when the color used for data point labels changes to color.

Notification signal of property pointLabelsColorᅟ .

pointLabelsFont()#
Return type:

QFont

Getter of property pointLabelsFontᅟ .

pointLabelsFontChanged(font)#
Parameters:

fontQFont

This signal is emitted when the font used for data point labels changes to font.

Notification signal of property pointLabelsFontᅟ .

pointLabelsFormat()#
Return type:

str

Getter of property pointLabelsFormatᅟ .

pointLabelsFormatChanged(format)#
Parameters:

format – str

This signal is emitted when the format of data point labels changes to format.

Notification signal of property pointLabelsFormatᅟ .

pointLabelsVisibilityChanged(visible)#
Parameters:

visible – bool

This signal is emitted when the visibility of the data point labels changes to visible.

Notification signal of property pointLabelsVisibleᅟ .

pointLabelsVisible()#
Return type:

bool

Getter of property pointLabelsVisibleᅟ .

pointRemoved(index)#
Parameters:

index – int

This signal is emitted when a point is removed from the position specified by index.

See also

remove()

pointReplaced(index)#
Parameters:

index – int

This signal is emitted when a point is replaced at the position specified by index.

See also

replace()

points()#
Return type:

.list of QPointF

Returns the points in the series.

pointsConfiguration()#
Return type:

Dictionary with keys of type .int and values of type QXYSeries.PointConfiguration.

Returns a map with points’ indexes as keys and points’ configuration as values.

pointsConfigurationChanged(configuration)#
Parameters:

configuration – Dictionary with keys of type .int and values of type QXYSeries.PointConfiguration.

pointsRemoved(index, count)#
Parameters:
  • index – int

  • count – int

This signal is emitted when the number of points specified by count is removed starting at the position specified by index.

pointsReplaced()#

This signal is emitted when all points are replaced with other points.

See also

replace()

pointsVector()#
Return type:

.list of QPointF

Note

This function is deprecated.

Use points() instead. Returns the points in the series.

pointsVisible()#
Return type:

bool

Getter of property pointsVisibleᅟ .

pressed(point)#
Parameters:

pointQPointF

This signal is emitted when the user presses the data point point in the chart and holds down the mouse button.

released(point)#
Parameters:

pointQPointF

This signal is emitted when the user releases the mouse press on the data point specified by point.

remove(point)#
Parameters:

pointQPointF

Removes the data point point from the series.

See also

pointRemoved()

remove(index)
Parameters:

index – int

Removes the point at the position specified by index from the series.

See also

pointRemoved()

remove(x, y)
Parameters:
  • x – float

  • y – float

Removes the point that has the coordinates x and y from the series.

See also

pointRemoved()

removePoints(index, count)#
Parameters:
  • index – int

  • count – int

Removes the number of points specified by count from the series starting at the position specified by index.

See also

pointsRemoved()

replace(points)#
Parameters:

points – .list of QPointF

Replaces the current points with the points specified by points.

Note

This is much faster than replacing data points one by one, or first clearing all data, and then appending the new data. Emits pointsReplaced() when the points have been replaced.

See also

pointsReplaced()

replace(oldPoint, newPoint)
Parameters:

Replaces the point specified by oldPoint with the one specified by newPoint.

See also

pointReplaced()

replace(index, newPoint)
Parameters:
  • index – int

  • newPointQPointF

Replaces the point at the position specified by index with the point specified by newPoint.

See also

pointReplaced()

replace(index, newX, newY)
Parameters:
  • index – int

  • newX – float

  • newY – float

Replaces the point at the position specified by index with the point that has the coordinates newX and newY.

See also

pointReplaced()

replace(oldX, oldY, newX, newY)
Parameters:
  • oldX – float

  • oldY – float

  • newX – float

  • newY – float

Replaces the point with the coordinates oldX and oldY with the point with the coordinates newX and newY. Does nothing if the old point does not exist.

See also

pointReplaced()

selectAllPoints()#

Marks all points in the series as selected,

selectPoint(index)#
Parameters:

index – int

Marks point at index as selected.

selectPoints(indexes)#
Parameters:

indexes – .list of int

Marks multiple points passed in a indexes list as selected.

selectedColor()#
Return type:

QColor

selectedColorChanged(color)#
Parameters:

colorQColor

Notification signal of property selectedColorᅟ .

selectedLightMarker()#
Return type:

QImage

Returns the image used for drawing markers on selected series’ points.

The default value is QImage(), meaning usual lightMarker() will be painted.

This is equivalent to selectedColor if you prefer light markers over normal points, but still want to distinguish selected points.

selectedLightMarkerChanged(selectedLightMarker)#
Parameters:

selectedLightMarkerQImage

selectedPoints()#
Return type:

.list of int

Returns a list of points indexes marked as selected. Selected points are visible regardless of points visibility.

selectedPointsChanged()#

This signal is emitted when the points selection changes.

setBestFitLineColor(color)#
Parameters:

colorQColor

Setter of property bestFitLineColorᅟ .

setBestFitLinePen(pen)#
Parameters:

penQPen

setBestFitLineVisible([visible=true])#
Parameters:

visible – bool

Setter of property bestFitLineVisibleᅟ .

setBrush(brush)#
Parameters:

brushQBrush

Sets the brush used for drawing points on the chart to brush. If the brush is not defined, the brush from the chart theme setting is used.

See also

brush() setTheme()

setColor(color)#
Parameters:

colorQColor

See also

color()

Setter of property colorᅟ .

setLightMarker(lightMarker)#
Parameters:

lightMarkerQImage

Sets the image used for drawing markers on each point of the series as the value of lightMarker.

The default value is a default-QImage() (QImage::isNull() == true), meaning no light marker will be painted. You can reset back to default (disabled) by calling this function with a null QImage (QImage()).

The light markers visualize the data points of this series and as such are an alternative to setPointsVisible(true). If a light marker is set with this method, visible points as set with setPointsVisible(true) are not displayed.

Unlike the elements of QScatterSeries the light markers are not represented by QGraphicsItem, but are just painted (no objects created). However, the mouse-event-signals of QXYSeries behave the same way, meaning that you’ll get the exact domain value of the point if you click/press/hover the light marker. You’ll still get the in between domain value if you click on the line. The light markers are above the line in terms of painting as well as events.

See also

lightMarker()

setMarkerSize(size)#
Parameters:

size – float

Sets the size of the marker used to render points in the series.

The default size is 15.0.

See also

markerSize

setPen(pen)#
Parameters:

penQPen

Sets the pen used for drawing points on the chart to pen. If the pen is not defined, the pen from the chart theme is used.

See also

pen() setTheme()

setPointConfiguration(index, configuration)#
Parameters:
  • index – int

  • configuration – Dictionary with keys of type .QXYSeries.PointConfiguration and values of type QVariant.

Enables customizing the appearance of a point located at index with desired configuration.

With points configuration you can change various aspects of every point’s appearance.

A point’s configuration is represented as a hash map with pointConfiguration keys and QVariant values. For example:

QLineSeries *series = new QLineSeries();
series->setName("Customized series");
series->setPointsVisible(true);

*series << QPointF(0, 6) << QPointF(2, 4) << QPointF(3, 6) << QPointF(7, 4) << QPointF(10, 5)
        << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3)
        << QPointF(20, 2);

QChart *chart = new QChart();
chart->addSeries(series);
chart->createDefaultAxes();

QHash<QXYSeries::PointConfiguration, QVariant> conf;
conf[QXYSeries::PointConfiguration::Color] = QColor(Qt::red);
conf[QXYSeries::PointConfiguration::Size] = 8;
conf[QXYSeries::PointConfiguration::LabelVisibility] = true;

series->setPointConfiguration(4, conf);

conf.remove(QXYSeries::PointConfiguration::Color);
conf[QXYSeries::PointConfiguration::LabelFormat] = "This Point";
series->setPointConfiguration(6, conf);

In this example, you can see a default QLineSeries with 10 points and with changed configuration of two points. Both changed points are visibly bigger than the others with a look derived from the series configuration. By default, points don’t have labels, but the point at index 4 has a label thanks to the LabelVisibility and LabelFormat configuration values. The point at index 6 has a custom label This Point thanks to the LabelFormat configuration value. Below is an example of a chart created in this way:

setPointConfiguration(index, key, value)
Parameters:
  • index – int

  • keyPointConfiguration

  • value – object

Enables customizing a particular aspect of a point’s configuration.

Note

Points configuration concept provides a flexible way to configure various aspects of a point’s appearance. Thus, values need to have an elastic type such as QVariant. See PointConfiguration to see what value should be passed for certain key.

setPointLabelsClipping([enabled=true])#
Parameters:

enabled – bool

Setter of property pointLabelsClippingᅟ .

setPointLabelsColor(color)#
Parameters:

colorQColor

Setter of property pointLabelsColorᅟ .

setPointLabelsFont(font)#
Parameters:

fontQFont

Setter of property pointLabelsFontᅟ .

setPointLabelsFormat(format)#
Parameters:

format – str

Setter of property pointLabelsFormatᅟ .

setPointLabelsVisible([visible=true])#
Parameters:

visible – bool

Setter of property pointLabelsVisibleᅟ .

setPointSelected(index, selected)#
Parameters:
  • index – int

  • selected – bool

Marks point at given index as either selected or deselected as specified by selected.

Note

Selected points are drawn using the selected color if it was specified. Emits selectedPointsChanged

setPointsConfiguration(pointsConfiguration)#
Parameters:

pointsConfiguration – Dictionary with keys of type .int and values of type QXYSeries.PointConfiguration.

Enables customizing the configuration of multiple points as specified by pointsConfiguration.

setPointsVisible([visible=true])#
Parameters:

visible – bool

See also

pointsVisible()

Setter of property pointsVisibleᅟ .

setSelectedColor(color)#
Parameters:

colorQColor

Setter of property selectedColorᅟ .

setSelectedLightMarker(selectedLightMarker)#
Parameters:

selectedLightMarkerQImage

Sets the image used for drawing markers on selected series’s points to selectedLightMarker.

The default value is QImage(), meaning usual lightMarker() will be painted.

This is an equivalent for selectedColor if you prefer light markers over normal points, but still want to distinguish selected points.

sizeBy(sourceData, minSize, maxSize)#
Parameters:
  • sourceData – .list of qreal

  • minSize – float

  • maxSize – float

Sets the points’ sizes according to a passed list of values. Values from sourceData are sorted and mapped to a point size which is between minSize and maxSize.

Note

If sourceData length is smaller than number of points in the series, then size of the points at the end of the series will stay the same.

toggleSelection(indexes)#
Parameters:

indexes – .list of int

Changes selection state of points at given indexes to the opposite one. Makes