May 2019
Intermediate to advanced
542 pages
13h 37m
English
The final thing that we might want to fix in this chart is the legend. This is the part of the chart that explains which color goes with which bar set. The legend is represented by a QLegend object, which is automatically created and updated by the QChart object as we add bar sets or series objects.
We can retrieve the chart's QLegend object using the legend() accessor method:
legend = chart.legend()
By default, the legend doesn't have a background and simply draws directly on the chart background. We can change that to improve readability, as follows:
legend.setBackgroundVisible(True) legend.setBrush( qtg.QBrush(qtg.QColor('white')))
We first turn on the background by setting backgroundVisible to True and then configuring ...
Read now
Unlock full access