Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. PySide6 QLineSeries doesn't plot correctly
QtWS25 Last Chance

PySide6 QLineSeries doesn't plot correctly

Scheduled Pinned Locked Moved Unsolved Qt for Python
3 Posts 2 Posters 89 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jronald
    wrote 23 days ago last edited by
    #1

    Versions

    Python             3.13.2
    PySide6            6.9.0
    PySide6_Addons     6.9.0
    PySide6_Essentials 6.9.0
    shiboken6          6.9.0
    

    Codes 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

    ed5b8322-8def-46ad-868d-66687dca7df1-image.png

    J 1 Reply Last reply 23 days ago
    0
    • J jronald
      23 days ago

      Versions

      Python             3.13.2
      PySide6            6.9.0
      PySide6_Addons     6.9.0
      PySide6_Essentials 6.9.0
      shiboken6          6.9.0
      

      Codes 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

      ed5b8322-8def-46ad-868d-66687dca7df1-image.png

      J Offline
      J Offline
      JonB
      wrote 23 days ago last edited by
      #2

      @jronald
      Not sure why this is going wrong. Try playing with combinations of: add the series before the axes, remove series' own axes, use createDefaultAxes(). Any difference?

      Also FWIW whatever the cause this should not be a PySide6/Python issue, rather the underlying QtCharts code must be the problem.

      J 1 Reply Last reply 16 days ago
      0
      • J JonB
        23 days ago

        @jronald
        Not sure why this is going wrong. Try playing with combinations of: add the series before the axes, remove series' own axes, use createDefaultAxes(). Any difference?

        Also FWIW whatever the cause this should not be a PySide6/Python issue, rather the underlying QtCharts code must be the problem.

        J Offline
        J Offline
        jronald
        wrote 16 days ago last edited by jronald
        #3

        @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. QwtArraySeriesData is not ported for python.
        Now I'm using matplotlib with qtagg backend, it works fine.
        It's said that QtGraphs is going to replace QtCharts, but the API in C++ is not complete so far, I'll follow it.

        Thanks

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved