PySide6 QLineSeries doesn't plot correctly
-
Versions
Python 3.13.2 PySide6 6.9.0 PySide6_Addons 6.9.0 PySide6_Essentials 6.9.0 shiboken6 6.9.0Codes for the chart
def initChart(self): self.axis_x = QValueAxis() self.axis_x.setTitleText("x") self.axis_y = QValueAxis() self.axis_y.setTitleText("y") self.series = QLineSeries() self.series.setName("Line Series") self.series.append(0, 6) self.series.append(1, 4) self.series.append(2, 5) self.series.attachAxis(self.axis_x) self.series.attachAxis(self.axis_y) self.axis_x.setRange(0, 2) self.axis_x.setTickCount(3) self.axis_y.setRange(0, 6) self.axis_y.setTickCount(7) self.chart = QChart() self.chart.setAnimationOptions(QChart.AllAnimations) self.chart.addAxis(self.axis_x, Qt.AlignBottom) self.chart.addAxis(self.axis_y, Qt.AlignLeft) self.chart.addSeries(self.series) self.ui.chartView.setChart(self.chart) self.ui.chartView.setRenderHint(QPainter.Antialiasing)Result

-
Versions
Python 3.13.2 PySide6 6.9.0 PySide6_Addons 6.9.0 PySide6_Essentials 6.9.0 shiboken6 6.9.0Codes for the chart
def initChart(self): self.axis_x = QValueAxis() self.axis_x.setTitleText("x") self.axis_y = QValueAxis() self.axis_y.setTitleText("y") self.series = QLineSeries() self.series.setName("Line Series") self.series.append(0, 6) self.series.append(1, 4) self.series.append(2, 5) self.series.attachAxis(self.axis_x) self.series.attachAxis(self.axis_y) self.axis_x.setRange(0, 2) self.axis_x.setTickCount(3) self.axis_y.setRange(0, 6) self.axis_y.setTickCount(7) self.chart = QChart() self.chart.setAnimationOptions(QChart.AllAnimations) self.chart.addAxis(self.axis_x, Qt.AlignBottom) self.chart.addAxis(self.axis_y, Qt.AlignLeft) self.chart.addSeries(self.series) self.ui.chartView.setChart(self.chart) self.ui.chartView.setRenderHint(QPainter.Antialiasing)Result

@jronald
Not sure why this is going wrong. Try playing with combinations of: add the series before the axes, remove series' own axes, usecreateDefaultAxes(). Any difference?Also FWIW whatever the cause this should not be a PySide6/Python issue, rather the underlying QtCharts code must be the problem.
-
@jronald
Not sure why this is going wrong. Try playing with combinations of: add the series before the axes, remove series' own axes, usecreateDefaultAxes(). Any difference?Also FWIW whatever the cause this should not be a PySide6/Python issue, rather the underlying QtCharts code must be the problem.
@JonB said in PySide6 QLineSeries doesn't plot correctly:
this should not be a PySide6/Python issue
Yes, https://bugreports.qt.io/browse/PYSIDE-3083
For it seems not so robust, I tries PythonQwt, but it is not complete, e.g.
QwtArraySeriesDatais not ported for python.
Now I'm usingmatplotlibwith qtagg backend, it works fine.
It's said thatQtGraphsis going to replaceQtCharts, but the API in C++ is not complete so far, I'll follow it.Thanks