class QGraphsTheme

QGraphsTheme class provides a visual style for graphs. More

Inheritance diagram of PySide6.QtGraphs.QGraphsTheme

Added in version 6.8.

Synopsis

Properties

Methods

Slots

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

Warning

This section contains snippets that were automatically translated from C++ to Python and may contain errors.

Specifies visual properties that affect the whole graph. There are several built-in themes that can be used as is or modified freely.

Themes can be created from scratch using the UserDefined enum value. Creating a theme using the default constructor produces a new user-defined theme.

Customizing Theme

The default theme is QtGreen , but it is possible to customize each property.

The following table lists the properties controlled by a theme and the default values for UserDefined .

Property

Default Value

backgroundVisible

true

seriesColors

Qt::black

seriesGradients

QLinearGradient. Essentially fully black.

colorStyle

Uniform

labelFont

QFont

gridVisible

true

labelBackgroundVisible

true

labelBorderVisible

true

labelsVisible

true

Usage Examples

Creating a built-in theme without any modifications:

theme = QGraphsTheme()

Creating a built-in theme and modifying some properties:

theme = QGraphsTheme()
theme.setBackgroundVisible(False)
theme.setLabelBackgroundVisible(False)

Modifying a user-defined theme. The theme has been created the same way it was in the previous snippets:

theme.setTheme(QGraphsTheme.Theme.UserDefined)
theme.setBackgroundColor(QColor(QRgb(0x99ca53)))
theme.setBackgroundVisible(True)
colors = { QColor(QRgb(0x209fdf)) }
theme.setSeriesColors(colors)
theme.setColorStyle(QGraphsTheme.ColorStyle.Uniform)
theme.setLabelFont(QFont("Impact", 35))
theme.setGridVisible(True)
gridline = theme.grid()
gridline.setMainColor(QColor(QRgb(0x99ca53)))
theme.setGrid(gridline)
theme.setLabelBackgroundColor(QColor(0xf6, 0xa6, 0x25, 0xa0))
theme.setLabelBackgroundVisible(True)
theme.setLabelBorderVisible(True)
theme.setLabelTextColor(QColor(QRgb(0x404044)))
theme.setMultiHighlightColor(QColor(QRgb(0x6d5fd5)))
theme.setSingleHighlightColor(QColor(QRgb(0xf6a625)))
theme.setBackgroundColor(QColor(QRgb(0xffffff)))

Modifying some properties after theme has been set to a graph:

quickWidget = QQuickWidget()
bars = Q3DBarsWidgetItem()
bars.setWidget(quickWidget)
bars.widget().setMinimumSize(QSize(512, 512))
bars.activeTheme().setTheme(QGraphsTheme.Theme.MixSeries)
color = { QColor(Qt.red) }
bars.activeTheme().setSeriesColors(color)
bars.activeTheme().setSingleHighlightColor(Qt.yellow)
class Theme

Built-in themes.

Constant

Description

QGraphsTheme.Theme.QtGreen

A light theme with green as the base color.

QGraphsTheme.Theme.QtGreenNeon

A light theme with green neon as the base color.

QGraphsTheme.Theme.MixSeries

A mixed theme with various colors.

QGraphsTheme.Theme.OrangeSeries

A theme with Orange as the base color.

QGraphsTheme.Theme.YellowSeries

A theme with Yellow as the base color.

QGraphsTheme.Theme.BlueSeries

A theme with Blue as the base color.

QGraphsTheme.Theme.PurpleSeries

A theme with Purple as the base color.

QGraphsTheme.Theme.GreySeries

A theme with Grey as the base color.

QGraphsTheme.Theme.UserDefined

A user-defined theme. For more information, see Customizing Theme .

class ColorStyle

Gradient types.

Constant

Description

QGraphsTheme.ColorStyle.Uniform

Objects are rendered in a single color. The color used is specified in seriesColors , singleHighlightColor and multiHighlightColor properties.

QGraphsTheme.ColorStyle.ObjectGradient

Objects are colored using a full gradient for each object regardless of object height. The gradient used is specified in seriesGradients , singleHighlightGradient and multiHighlightGradient properties.

QGraphsTheme.ColorStyle.RangeGradient

Objects are colored using a portion of the full gradient determined by the object’s height and its position on the Y-axis. The gradient used is specified in seriesGradients , singleHighlightGradient and multiHighlightGradient properties.

class ForceTheme
class ColorScheme

Represents the color scheme of the graph.

Constant

Description

QGraphsTheme.ColorScheme.Automatic

The background colors follow the platform color scheme if available. If unavailable, the Light appearance is used.

QGraphsTheme.ColorScheme.Light

The background colors are lighter than the text color, i.e. the theme is light.

QGraphsTheme.ColorScheme.Dark

The background colors are darker than the text color, i.e. the theme is dark.

See also

ColorScheme

class GradientQMLStyle

Note

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

property axisXᅟ: QGraphsLine
Access functions:
property axisXLabelFontᅟ: QFont

This property holds The font to be used for labels on x axis..

Access functions:
property axisYᅟ: QGraphsLine
Access functions:
property axisYLabelFontᅟ: QFont

This property holds The font to be used for labels on y axis..

Access functions:
property axisZᅟ: QGraphsLine
Access functions:
property axisZLabelFontᅟ: QFont

This property holds The font to be used for labels on z axis..

Access functions:
property backgroundColorᅟ: QColor

This property holds The color of the view the graph is drawn into. The default value depends on colorScheme ..

Access functions:
property backgroundVisibleᅟ: bool

This property holds Whether the background is visible..

The background is drawn by using the value of backgroundColor . The default value is true.

Access functions:
property borderColorsᅟ: list of QColor

This property holds The list of border colors to be used for all the objects in the graph, series by series..

If there are more series than colors, the color list wraps and starts again with the first color in the list.

Has no immediate effect if colorStyle is not Uniform.

Access functions:
property borderWidthᅟ: float

This property holds The width of borders in graph if any The default value is 1.0..

Access functions:
property colorSchemeᅟ: QGraphsTheme.ColorScheme

The color scheme of the graph in use.

See also

ColorScheme

Access functions:
property colorStyleᅟ: QGraphsTheme.ColorStyle

The style of the graph colors. One of ColorStyle enum values.

This value can be overridden by setting Abstract3DSeries.colorStyle explicitly in the series.

Note

This property does not have an effect in Qt Graphs for 2D.

See also

ColorStyle

Access functions:
property gridᅟ: QGraphsLine
Access functions:
property gridVisibleᅟ: bool

This property holds Whether the grid lines are drawn..

This value affects all grid lines. The default value is true.

Access functions:
property labelBackgroundColorᅟ: QColor

This property holds The color of the label backgrounds..

Has no effect if labelBackgroundVisible is false. The default value depends on colorScheme .

Access functions:
property labelBackgroundVisibleᅟ: bool

This property holds Whether the label is drawn with a color background or with a fully transparent background..

The labelBackgroundColor value (including alpha) is used for drawing the background.

Labels with a background are drawn to equal sizes per axis based on the longest label, and the text is centered in them. Labels without a background are drawn as is and are left or right aligned based on their position in the graph. The default value is true.

Access functions:
property labelBorderVisibleᅟ: bool

This property holds Whether label borders are drawn for labels that have a background..

Has no effect if labelBackgroundVisible is false. The default value is true.

Access functions:
property labelFontᅟ: QFont

This property holds The font to be used for labels..

Access functions:
property labelTextColorᅟ: QColor

This property holds The color of the font used for labels. The default value depends on colorScheme ..

Access functions:
property labelsVisibleᅟ: bool

This property holds Whether labels are drawn at all..

If this is false, all other label properties have no effect. The default value is true.

Access functions:
property multiHighlightColorᅟ: QColor

This property holds The highlight color for selected objects..

Used if selectionMode has the QtGraphs3D::SelectionFlag::Row or QtGraphs3D::SelectionFlag::Column flag set. The default value depends on colorScheme .

Access functions:
property plotAreaBackgroundColorᅟ: QColor

This property holds The color of the graph plot area background. The default value depends on colorScheme ..

Access functions:
property plotAreaBackgroundVisibleᅟ: bool

This property holds Whether the plot area background is visible..

The background is drawn by using the value of plotAreaBackgroundColor . The default value is true.

Access functions:
property seriesColorsᅟ: list of QColor

This property holds The list of base colors to be used for all the objects in the graph, series by series..

If there are more series than colors, the color list wraps and starts again with the first color in the list.

Has no immediate effect if colorStyle is not Uniform.

This value can be overridden by setting the baseColor explicitly in the series.

Access functions:
property singleHighlightColorᅟ: QColor

This property holds The highlight color for a selected object..

Used if selectionMode has the QtGraphs3D::SelectionFlag::Item flag set. The default value depends on colorScheme .

Access functions:
property themeᅟ: QGraphsTheme.Theme

The type of the theme. If no type is set, the type is QtGreen . Changing the theme type after the item has been constructed will change all other properties of the theme to what the predefined theme specifies. Changing the theme type of the active theme of the graph will also reset all attached series to use the new theme.

Access functions:
__init__([parent=None])
Parameters:

parentQObject

axisX()
Return type:

QGraphsLine

See also

setAxisX()

Getter of property axisXᅟ .

axisXChanged()

Notification signal of property axisXᅟ .

axisXLabelFont()
Return type:

QFont

Getter of property axisXLabelFontᅟ .

axisXLabelFontChanged()

Notification signal of property axisXLabelFontᅟ .

axisY()
Return type:

QGraphsLine

See also

setAxisY()

Getter of property axisYᅟ .

axisYChanged()

Notification signal of property axisYᅟ .

axisYLabelFont()
Return type:

QFont

Getter of property axisYLabelFontᅟ .

axisYLabelFontChanged()

Notification signal of property axisYLabelFontᅟ .

axisZ()
Return type:

QGraphsLine

See also

setAxisZ()

Getter of property axisZᅟ .

axisZChanged()

Notification signal of property axisZᅟ .

axisZLabelFont()
Return type:

QFont

Getter of property axisZLabelFontᅟ .

axisZLabelFontChanged()

Notification signal of property axisZLabelFontᅟ .

backgroundColor()
Return type:

QColor

Getter of property backgroundColorᅟ .

backgroundColorChanged()

Notification signal of property backgroundColorᅟ .

backgroundVisibleChanged()

Notification signal of property backgroundVisibleᅟ .

borderColors()
Return type:

.list of QColor

Getter of property borderColorsᅟ .

borderColorsChanged()

Notification signal of property borderColorsᅟ .

borderWidth()
Return type:

float

See also

setBorderWidth()

Getter of property borderWidthᅟ .

borderWidthChanged()

Notification signal of property borderWidthᅟ .

colorScheme()
Return type:

ColorScheme

See also

setColorScheme()

Getter of property colorSchemeᅟ .

colorSchemeChanged()

Notification signal of property colorSchemeᅟ .

colorStyle()
Return type:

ColorStyle

See also

setColorStyle()

Getter of property colorStyleᅟ .

colorStyleChanged(type)
Parameters:

typeColorStyle

Notification signal of property colorStyleᅟ .

dirtyBits()
Return type:

QGraphsThemeDirtyBitField

grid()
Return type:

QGraphsLine

See also

setGrid()

Getter of property gridᅟ .

gridChanged()

Notification signal of property gridᅟ .

gridVisibleChanged()

Notification signal of property gridVisibleᅟ .

handleBaseColorUpdate()
handleBaseGradientUpdate()
isBackgroundVisible()
Return type:

bool

Getter of property backgroundVisibleᅟ .

isGridVisible()
Return type:

bool

Getter of property gridVisibleᅟ .

isLabelBackgroundVisible()
Return type:

bool

Getter of property labelBackgroundVisibleᅟ .

isLabelBorderVisible()
Return type:

bool

Getter of property labelBorderVisibleᅟ .

isPlotAreaBackgroundVisible()
Return type:

bool

Getter of property plotAreaBackgroundVisibleᅟ .

labelBackgroundColor()
Return type:

QColor

Getter of property labelBackgroundColorᅟ .

labelBackgroundColorChanged()

Notification signal of property labelBackgroundColorᅟ .

labelBackgroundVisibleChanged()

Notification signal of property labelBackgroundVisibleᅟ .

labelBorderVisibleChanged()

Notification signal of property labelBorderVisibleᅟ .

labelFont()
Return type:

QFont

See also

setLabelFont()

Getter of property labelFontᅟ .

labelFontChanged()

Notification signal of property labelFontᅟ .

labelTextColor()
Return type:

QColor

Getter of property labelTextColorᅟ .

labelTextColorChanged()

Notification signal of property labelTextColorᅟ .

labelsVisible()
Return type:

bool

Getter of property labelsVisibleᅟ .

labelsVisibleChanged()

Notification signal of property labelsVisibleᅟ .

multiHighlightColor()
Return type:

QColor

Getter of property multiHighlightColorᅟ .

multiHighlightColorChanged(color)
Parameters:

colorQColor

Notification signal of property multiHighlightColorᅟ .

multiHighlightGradient()
Return type:

QLinearGradient

multiHighlightGradientChanged(gradient)
Parameters:

gradientQLinearGradient

multiHighlightGradientQMLChanged()
plotAreaBackgroundColor()
Return type:

QColor

Getter of property plotAreaBackgroundColorᅟ .

plotAreaBackgroundColorChanged()

Notification signal of property plotAreaBackgroundColorᅟ .

plotAreaBackgroundVisibleChanged()

Notification signal of property plotAreaBackgroundVisibleᅟ .

resetColorTheme()
resetDirtyBits()
resetThemeDirty()
seriesColors()
Return type:

.list of QColor

Getter of property seriesColorsᅟ .

seriesColorsChanged(list)
Parameters:

list – .list of QColor

Notification signal of property seriesColorsᅟ .

seriesGradients()
Return type:

.list of QLinearGradient

Returns the list of series gradients used by theme.

seriesGradientsChanged(list)
Parameters:

list – .list of QLinearGradient

setAxisX(newAxisX)
Parameters:

newAxisXQGraphsLine

See also

axisX()

Setter of property axisXᅟ .

setAxisXLabelFont(newAxisXLabelFont)
Parameters:

newAxisXLabelFontQFont

See also

axisXLabelFont()

Setter of property axisXLabelFontᅟ .

setAxisY(newAxisY)
Parameters:

newAxisYQGraphsLine

See also

axisY()

Setter of property axisYᅟ .

setAxisYLabelFont(newAxisYLabelFont)
Parameters:

newAxisYLabelFontQFont

See also

axisYLabelFont()

Setter of property axisYLabelFontᅟ .

setAxisZ(newAxisZ)
Parameters:

newAxisZQGraphsLine

See also

axisZ()

Setter of property axisZᅟ .

setAxisZLabelFont(newAxisZLabelFont)
Parameters:

newAxisZLabelFontQFont

See also

axisZLabelFont()

Setter of property axisZLabelFontᅟ .

setBackgroundColor(newBackgroundColor)
Parameters:

newBackgroundColorQColor

Setter of property backgroundColorᅟ .

setBackgroundVisible(newBackgroundVisible)
Parameters:

newBackgroundVisible – bool

Setter of property backgroundVisibleᅟ .

setBorderColors(newBorderColors)
Parameters:

newBorderColors – .list of QColor

See also

borderColors()

Setter of property borderColorsᅟ .

setBorderWidth(newBorderWidth)
Parameters:

newBorderWidth – float

See also

borderWidth()

Setter of property borderWidthᅟ .

setColorScheme(newColorScheme)
Parameters:

newColorSchemeColorScheme

See also

colorScheme()

Setter of property colorSchemeᅟ .

setColorStyle(newColorStyle)
Parameters:

newColorStyleColorStyle

See also

colorStyle()

Setter of property colorStyleᅟ .

setGrid(newGrid)
Parameters:

newGridQGraphsLine

See also

grid()

Setter of property gridᅟ .

setGridVisible(newGridVisibility)
Parameters:

newGridVisibility – bool

See also

isGridVisible()

Setter of property gridVisibleᅟ .

setLabelBackgroundColor(newLabelBackgroundColor)
Parameters:

newLabelBackgroundColorQColor

Setter of property labelBackgroundColorᅟ .

setLabelBackgroundVisible(newLabelBackgroundVisibility)
Parameters:

newLabelBackgroundVisibility – bool

Setter of property labelBackgroundVisibleᅟ .

setLabelBorderVisible(newLabelBorderVisibility)
Parameters:

newLabelBorderVisibility – bool

Setter of property labelBorderVisibleᅟ .

setLabelFont(newFont)
Parameters:

newFontQFont

See also

labelFont()

Setter of property labelFontᅟ .

setLabelTextColor(newLabelTextColor)
Parameters:

newLabelTextColorQColor

See also

labelTextColor()

Setter of property labelTextColorᅟ .

setLabelsVisible(newLabelsVisibility)
Parameters:

newLabelsVisibility – bool

See also

labelsVisible()

Setter of property labelsVisibleᅟ .

setMultiHighlightColor(newMultiHighlightColor)
Parameters:

newMultiHighlightColorQColor

Setter of property multiHighlightColorᅟ .

setMultiHighlightGradient(gradient)
Parameters:

gradientQLinearGradient

setPlotAreaBackgroundColor(newBackgroundColor)
Parameters:

newBackgroundColorQColor

Setter of property plotAreaBackgroundColorᅟ .

setPlotAreaBackgroundVisible(newBackgroundVisibility)
Parameters:

newBackgroundVisibility – bool

Setter of property plotAreaBackgroundVisibleᅟ .

setSeriesColors(newSeriesColors)
Parameters:

newSeriesColors – .list of QColor

See also

seriesColors()

Setter of property seriesColorsᅟ .

setSeriesGradients(newSeriesGradients)
Parameters:

newSeriesGradients – .list of QLinearGradient

Sets newSeriesGradients as the series gradients for the theme.

setSingleHighlightColor(newSingleHighlightColor)
Parameters:

newSingleHighlightColorQColor

Setter of property singleHighlightColorᅟ .

setSingleHighlightGradient(gradient)
Parameters:

gradientQLinearGradient

setTheme(newTheme[, force=QGraphsTheme.ForceTheme.No])
Parameters:

See also

theme()

singleHighlightColor()
Return type:

QColor

Getter of property singleHighlightColorᅟ .

singleHighlightColorChanged(color)
Parameters:

colorQColor

Notification signal of property singleHighlightColorᅟ .

singleHighlightGradient()
Return type:

QLinearGradient

singleHighlightGradientChanged(gradient)
Parameters:

gradientQLinearGradient

singleHighlightGradientQMLChanged()
theme()
Return type:

Theme

See also

setTheme()

Getter of property themeᅟ .

themeChanged(theme)
Parameters:

themeTheme

Notification signal of property themeᅟ .

themeDirty()
Return type:

bool

update()