Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-898

Polar plot axes appear incorrectly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.12.1
    • 5.11.0, 5.11.2
    • PySide
    • None
    • macOS 10.14.2 and Python 3.6.6
    • macOS
    • 8b6fbbac601b78f0c0413218ec5d48c60bc014ed (pyside/pyside-setup/5.12)

    Description

      I posted this on StackOverflow here. I've copied it over for convenience but the formatting on StackOverflow is probably better.

      I'm trying to make a polar plot using QtCharts by copying the example here using the source code found linked at the bottom of that page. I've converted the C++ code to PySide2 compatible code, and everything seems to mostly work (i.e. the plot shows up and the series are drawn), but for some reason, the angular axis is labelled incorrectly. When I run my code, the labels for angular axis overlap the labels for the radial axis, despite my adding the angular axis as follows:

      self.chart.addAxis(self.angularAxis, QtCharts.QtCharts.QPolarChart.PolarOrientationAngular)
      

      According to the docs, this is what I'm supposed to do for the angular axis, but it doesn't seem to be working. It ends up looking like the attached image.

      Below is the code that generates this.

       import sys
       from PySide2 import QtCore, QtWidgets, QtGui, QtCharts
      
       class Main(QtWidgets.QMainWindow):
           def __init__(self, parent=None):
               super(Main, self).__init__(parent)
               self.angularMin = 0
               self.angularMax = 360
      
               self.radialMin = -100
               self.radialMax = 100
      
               self.chart = QtCharts.QtCharts.QPolarChart()
               self.chart.setTitle("Example Chart")
      
               self.angularAxis = QtCharts.QtCharts.QValueAxis()
               self.angularAxis.setTickCount(9)
               self.angularAxis.setLabelFormat("%.1f")
               self.angularAxis.setShadesVisible(True)
               self.angularAxis.setShadesBrush(QtGui.QBrush(QtGui.QColor(249, 249, 255)))
               self.chart.addAxis(self.angularAxis, QtCharts.QtCharts.QPolarChart.PolarOrientationAngular)
      
               self.radialAxis = QtCharts.QtCharts.QValueAxis()
               self.radialAxis.setTickCount(9)
               self.radialAxis.setLabelFormat("%d")
               self.chart.addAxis(self.radialAxis, QtCharts.QtCharts.QPolarChart.PolarOrientationRadial)
      
               self.radialAxis.setRange(self.radialMin, self.radialMax);
               self.angularAxis.setRange(self.angularMin, self.angularMax);
      
               self.chartView = QtCharts.QtCharts.QChartView(self.chart)
               self.chartView.setRenderHint(QtGui.QPainter.Antialiasing);
               self.setCentralWidget(self.chartView)
      
       app = QtWidgets.QApplication(sys.argv)
       main = Main()
       main.show()
       sys.exit(app.exec_())
      

      Attachments

        For Gerrit Dashboard: PYSIDE-898
        # Subject Branch Project Status CR V

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            bgaud Ben Gaudiosi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes