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. QChart with QScatter series have inaccurate axes ? PySide6

QChart with QScatter series have inaccurate axes ? PySide6

Scheduled Pinned Locked Moved Unsolved Qt for Python
1 Posts 1 Posters 252 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.
  • E Offline
    E Offline
    eightfingers
    wrote on last edited by
    #1

    So I am testing out QChart to plot a simple scatter chart with points (0,0), (2,4), (3,8) and the resultant points are completely off.
    huh..PNG
    I am not sure where I did wrong here!

    import sys
    from PySide6.QtCore import Qt
    from PySide6.QtGui import QPainter
    from PySide6.QtWidgets import QMainWindow, QApplication
    from PySide6.QtCharts import QChart, QChartView, QScatterSeries, QValueAxis
    
    
    class TestChart(QMainWindow):
        def __init__(self):
            super().__init__()
    
            self.axisX = QValueAxis()
            self.axisX.setTickCount(10)
            self.axisX.setMin(-10)
            self.axisX.setMax(10)
            self.axisX.setTitleText("X")
    
            self.axisY = QValueAxis()
            self.axisY.setTickCount(10)
            self.axisY.setMin(-10)
            self.axisY.setMax(10)
            self.axisY.setTitleText("Y")
    
            self.series = QScatterSeries()
            self.series.append(0, 0)
            self.series.append(2, 4)
            self.series.append(3, 8)
    
            self.chart = QChart()
            self.chart.createDefaultAxes()
            self.chart.legend().hide()
            self.chart.addSeries(self.series)
            self.chart.setAxisX(self.axisX)
            self.chart.setAxisY(self.axisY)
    
            self.chart.setTitle("Simple Scatter chart test")
    
            self._chart_view = QChartView(self.chart)
            self._chart_view.setRenderHint(QPainter.Antialiasing)
    
            self.setCentralWidget(self._chart_view)
    
    
    if __name__ == "__main__":
        app = QApplication(sys.argv)
    
        window = TestChart()
        window.show()
        window.resize(440, 300)
        sys.exit(app.exec())
    
    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