May 2019
Intermediate to advanced
542 pages
13h 37m
English
The font and color of the labels used on the chart's axes must be set through our axis's objects:
axis_font = qtg.QFont('Mono', 16) axis_brush = qtg.QBrush(qtg.QColor('#EEF')) y_axis.setLabelsFont(axis_font) y_axis.setLabelsBrush(axis_brush)
Here, we've set the y axis font and color by using the setLabelsFont() and setLabelsBrush() methods, respectively. Note that we could set the x axis label font and color as well, but there isn't much point since we're not showing the x labels.
The axis objects also give us access to styling our grid lines, using the gridLinePen property:
grid_pen = qtg.QPen(qtg.QColor('silver')) grid_pen.setDashPattern([1, 1, 1, 0]) x_axis.setGridLinePen(grid_pen) y_axis.setGridLinePen(grid_pen)
Here, we've ...
Read now
Unlock full access