In QGIS, I use the python console to generate image files through the composer. In particular, I am creating a map with a legend. The legend is too big. It occupies about 1/8 of the image. I would like to make the legend smaller.
The code that adds the legend to the composition is:
c = QgsComposition(mapRenderer) c.setPlotStyle(QgsComposition.Print) cleg = QgsComposerLegend(c) cleg.model().setLayerSet(mapRenderer.layerSet()) cleg.setItemPosition(0,45) c.addItem(cleg)
A legend is created, but it is too big. In order to make it smaller, I have been reading the documentation of the QgsComposerLegend and QgsComposerItem classes, with no positive results. In particular, I have been trying to change the legend size by typing
but the size does not change.
I think I might have to make the font smaller first. If that is the case, I should use setStyleFont, which depends on a QgsComposerLegendStyle object which I don't know how to retrieve (I have tried to use the rstyle function, but I don't know how to use it).
In summary, could you please provide an example on how to:
- Make the legend smaller
- Make the legend font smaller?