New answers tagged

5

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


1

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 )


0

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 ...


0

As of QGIS 3.16, you can do this directly via the Label precision option under Symbology. Just set the precision to 0. You can also use negative numbers to round to powers of 10.


1

You can set the map extent based on your line layer like this : ms = QgsMapSettings() context = QgsRenderContext.fromMapSettings(ms) ms.setLayers([line_layer]) rect = QgsRectangle(ms.fullExtent()) rect.scale(1.2) ms.setExtent(rect) map.setExtent(rect) layout.addLayoutItem(map) Then when you add the legend you can compare the extent of your layers with your ...


0

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)


4

Open "Layer Styling F7" panel. Select "Graduated". 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 ...


3

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:='...


0

Attribute table shows features controlled by Atlas if relation between tables has been done. Relations are defined in Project properties. Then on Atlas must select 'Relation children'.


1

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: overlay_intersects( 'limits') Then set a query on this layer to: legend=True Save changes You should only see the relevant polygons, but the ...


1

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)][0] legend.setAutoUpdateModel(False) root_admin = legend.model().rootGroup().findGroup('Limites ...


3

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 ...


1

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 ...


Top 50 recent answers are included