You should use rstyle method of legend. It returns reference to QgsLegendStyle object for legend components. Then, you can add spacing using setMargin function. Documentation for rstyle and setMargin.
legend.rstyle(QgsLegendStyle.Group).setMargin(QgsLegendStyle.Top, 10) # Top side, 10 mm
You must check fixed frame as pic shows to be able to resize legend and change aspect ratio
once you check fixed frame, the 'preserve aspect ratio' option is no longer grey out, as pic shows.
now you are free to drag to resize the legend ( aspect ratio will change when you drag )
You need add heading in symbology tab, here is my sample:
click zone_merge layer, open layer properties, click symbology tab
now, click the item for example, VC village commercial,
right click it, choose, "move to heading", choose 'new heading'
Then, you can click others, choose move to heading, .... and so on.
when you save
the legend will ...
You can set the map extent based on your line layer like this :
ms = QgsMapSettings()
context = QgsRenderContext.fromMapSettings(ms)
rect = QgsRectangle(ms.fullExtent())
Then when you add the legend you can compare the extent of your layers with your ...
A solution I have tested in QGIS :
Produce a line layer with the tool polygonstolines
In your legend add this layer and errase the department and region layer.
Activate the filter to show legend only for item inside atlas item (see capture under)
Open "Layer Styling F7" panel.
Select the related field.
Set "Method" to "Size".
Change number of "Classes".
Double-click on "Values" you want to change and change.
When you change a lower or upper value, previous and next symbol values are updated, too, accordingly. I am unsure ...
If you want the table to dynamically change its location relative to other objects (including growing from the bottom), you have to:
Set the "Reference point" to the bottom part.
Set the dynamic height of table1 and table2 in the Position and Size settings using the following expression:
6.2 + 6.2 * (1 + aggregate(layer:='table2', aggregate:='...
Make a rectangular polygon the same extent as your layout. I called mine 'limits'
Copy your polygons layer to a new layer, and create a new attribute 'legend' using the attribute calculator. I used this expression:
Then set a query on this layer to:
You should only see the relevant polygons, but the ...
Thank you Ben this code work ! To my side I tried this code and It work also
project = QgsProject().instance()
layout = project.layoutManager().layoutByName('Your Layout Name')
legend = [i for i in layout.items() if isinstance(i, QgsLayoutItemLegend)]
root_admin = legend.model().rootGroup().findGroup('Limites ...
There is only a small modification to be made to the code. You just need to get a reference to your legend group and remove the layer from the QgsLayerTreeGroup rather than the root group which is a QgsLayerTree object.
Please try the example below. I have used a group and layer name from your screenshot but you will need to change the layout name to match ...
This weird process randomly worked for me. I imported a map layout (lets call this map B) in ArcPro that I had previously saved in ArcMap (10.7) which was already right-justified. This legend showed up right-justified in ArcPro. I copied this right-justified legend in the ArcPro session into the other map tab I had open in ArcPro (map A) that I was trying to ...