QCategoryAxis

The QCategoryAxis class places named ranges on the axis. More

Inheritance diagram of PySide6.QtCharts.QCategoryAxis

Synopsis

Functions

Detailed Description

This class can be used to explain the underlying data by adding labeled categories. Unlike QBarCategoryAxis , QCategoryAxis allows the widths of the category ranges to be specified freely.

Example code on how to use QCategoryAxis :

../../_images/api_category_axis.png
QChartView *chartView = new QChartView;
QLineSeries *series = new QLineSeries;
// ...
chartView->chart()->addSeries(series);

QCategoryAxis *axisY = new QCategoryAxis;
axisY->setMin(0);
axisY->setMax(52);
axisY->setStartValue(15);
axisY->append("First", 20);
axisY->append("Second", 37);
axisY->append("Third", 52);
chartView->chart()->setAxisY(axisY, series);
class PySide6.QtCharts.QCategoryAxis([parent=None])
Parameters

parentPySide6.QtCore.QObject

Constructs an axis object that is a child of parent.

PySide6.QtCharts.QCategoryAxis.AxisLabelsPosition

This enum describes the position of the category labels.

Constant

Description

QCategoryAxis.AxisLabelsPositionCenter

Labels are centered to category.

QCategoryAxis.AxisLabelsPositionOnValue

Labels are positioned to the high end limit of the category.

PySide6.QtCharts.QCategoryAxis.append(label, categoryEndValue)
Parameters
  • label – str

  • categoryEndValue – float

Appends a new category to the axis with the label categoryLabel. A category label has to be unique. categoryEndValue specifies the high end limit of the category. It has to be greater than the high end limit of the previous category. Otherwise the method returns without adding a new category.

PySide6.QtCharts.QCategoryAxis.categoriesChanged()
PySide6.QtCharts.QCategoryAxis.categoriesLabels()
Return type

list of strings

Returns the list of the categories’ labels.

PySide6.QtCharts.QCategoryAxis.count()
Return type

int

Returns the number of categories.

PySide6.QtCharts.QCategoryAxis.endValue(categoryLabel)
Parameters

categoryLabel – str

Return type

float

Returns the high end limit of the category specified by categoryLabel.

PySide6.QtCharts.QCategoryAxis.labelsPosition()
Return type

AxisLabelsPosition

PySide6.QtCharts.QCategoryAxis.labelsPositionChanged(position)
Parameters

positionAxisLabelsPosition

PySide6.QtCharts.QCategoryAxis.remove(label)
Parameters

label – str

Removes a category specified by the label categoryLabel from the axis.

PySide6.QtCharts.QCategoryAxis.replaceLabel(oldLabel, newLabel)
Parameters
  • oldLabel – str

  • newLabel – str

Replaces an existing category label specified by oldLabel with newLabel. If the old label does not exist, the method returns without making any changes.

PySide6.QtCharts.QCategoryAxis.setLabelsPosition(position)
Parameters

positionAxisLabelsPosition

See also

labelsPosition()

PySide6.QtCharts.QCategoryAxis.setStartValue(min)
Parameters

min – float

Sets min to be the low end limit of the first category on the axis. If categories have already been added to the axis, the passed value must be less than the high end value of the already defined first category range. Otherwise nothing is done.

See also

startValue()

PySide6.QtCharts.QCategoryAxis.startValue([categoryLabel=""])
Parameters

categoryLabel – str

Return type

float

Returns the low end limit of the category specified by categoryLabel.

See also

setStartValue()