5

I have a legend with no title but there is still a large white space above the layer/subgroup title that I would like to remove. I tried using legend.setTitle("") and legend.setStyleFont(QgsLegendStyle.Title, QFont('Arial', 0)) but neither worked. I suspect this is a spacing issue rather than a font issue, but I don't see anything under setStyle that looks like it controls spacing.

enter image description here

1 Answer 1

10

You can use rstyle method of legend. You can set spacing using setMargin function. Documentation for rstyle and setMargin.

legend.rstyle(QgsLegendStyle.Title).setMargin(1) # 1 mm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.