Python 使QChart变大并正确显示标签

Python 使QChart变大并正确显示标签,python,pyqt5,pyside2,qtcharts,Python,Pyqt5,Pyside2,Qtcharts,以下是我的数据片段和QChart: 我想将图例对齐到右上角,并增加饼图的大小,以尽可能多地占据空间 我尝试了self.chart.legend().setAlignment(Qt.AlignRight | Qt.AlignTop),但这使图例不可见 self.chart = QtCharts.QChart() self.chart.legend().setVisible(1) self.chart.legend().setAlignment(Qt.AlignRight

以下是我的数据片段和QChart:

我想将图例对齐到右上角,并增加饼图的大小,以尽可能多地占据空间

我尝试了
self.chart.legend().setAlignment(Qt.AlignRight | Qt.AlignTop)
,但这使图例不可见

    self.chart = QtCharts.QChart()
    self.chart.legend().setVisible(1)
    self.chart.legend().setAlignment(Qt.AlignRight | Qt.AlignTop)
    self.series = QtCharts.QPieSeries()
    self.chart.addSeries(self.series)
    self.ui.graphicsView.setChart(self.chart)
    self.ui.graphicsView.setRenderHint(QPainter.Antialiasing)
    self.chart.setBackgroundVisible(0)