Skip to main content

QCustomScatterChart

Pro widget

QCustomScatterChart ships in Custom Widgets Pro. The free package under GPLv3 does not include it.

See plans

QCustomScatterChart

A painted x/y scatter plot.

Points in a cartesian plane, one colour per series, optionally sized by a third value (a bubble plot). The most conspicuous absence for a general chart library: nothing in the catalog plotted two continuous variables against each other.

QPainter only, NO QtCharts - Qt Charts is GPLv3-or-commercial with no LGPL option, so anything built on it cannot ship in a proprietary wheel (see docs/design/mui-charts-gap.md).

Axis ticks come from _chart_axis, shared with the other cartesian charts so they agree about where round numbers fall.

Data goes in with addSeries(name, points) in code, or pointsCsv in Qt Designer:

pointsCsv = "Alpha=1,2;2,4;3,9|Beta=1,5;2,3" name x,y pairs separated by ";", series by "|"

Emits pointHovered(int, int) and pointClicked(int, int) - series index and point index, or (-1, -1) for nothing.

At a glance

TierPro
Importfrom Custom_Widgets.QCustomScatterChart import QCustomScatterChart
Qt DesignerYes — drag it from the palette

Quick start

from Custom_Widgets.QCustomScatterChart import QCustomScatterChart

widget = QCustomScatterChart()

Dark theme

Colours come from the design tokens, so the widget follows the app theme with no extra work.

QCustomScatterChart in dark theme

Properties

Every property below is settable in code and in Qt Designer.

PropertyTypeDefault
pointsCsvstring
seriesColorsCsvstring
xAxisTitlestring
yAxisTitlestring
markerSizefloat7.0
markerShapeenum: circle/square/diamond/triangle``circle
markerOpacityfloat0.85
tickCountint5
showGridboolTrue
showAxesboolTrue
showLegendboolTrue
showTooltipboolTrue
gridColorcolor#e2e8f0
axisColorcolor#cbd5e1
labelColorcolor#64748b

Signals

Signal
pointClicked(int,int)
pointHovered(int,int)

Methods

MethodDescription
addSeries(name, points, color=None)Add a series.
axisColor(*args, **kwargs)Axis color.
clearSeries()Clear the series.
dataBounds()(xmin, xmax, ymin, ymax) across every series.
gridColor(*args, **kwargs)Grid color.
labelColor(*args, **kwargs)Label color.
mapPoint(x, y)Data coordinates -> widget coordinates.
markerOpacity(*args, **kwargs)Marker opacity.
markerShape(*args, **kwargs)Marker shape.
markerSize(*args, **kwargs)Marker size.
pointAt(pos, tolerance=None)(series, point) nearest a position within tolerance, else (-1, -1).
pointClicked(...)Point clicked.
pointCount()Point count.
pointHovered(...)Point hovered.
pointsCsv(*args, **kwargs)Points csv.
removeSeries(index)Remove a series.
series()Series.
seriesColor(index)Series color.
seriesColorsCsv(*args, **kwargs)Series colors csv.
seriesCount()Series count.
setSeries(series)Set the series.
showAxes(*args, **kwargs)Show the axes.
showGrid(*args, **kwargs)Show the grid.
showLegend(*args, **kwargs)Show the legend.
showTooltip(*args, **kwargs)Show the tooltip.
tickCount(*args, **kwargs)Tick count.
xAxisTitle(*args, **kwargs)X axis title.
xRange()X range.
yAxisTitle(*args, **kwargs)Y axis title.
yRange()Y range.

Theming

Colours come from the design tokens, so they follow the active theme. Roles used: accent, outline, on-surface, surface-muted.

See Design tokens.

Runnable example

A complete app using this widget lives at examples/PySide6/QCustomScatterChart/main.py.

QCustomAreaChart · QCustomBarChart · QCustomBeeswarm · QCustomBubbleChart · QCustomCandlestickChart · QCustomCompass · QCustomCompassDial · QCustomDivergingBarChart