Add Layout Legend
add_layout_legendPlace a legend on a QGIS print layout and link it to a map item, with optional size, position, title, and layer filtering to show only the layers you choose.
Instructions
Add a legend to a print layout, linked to a map item (defaults to the first map item). Position/size in mm. Optional layer_ids restricts the legend to specific layers.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"layout_name": "<layout_name>"
},
"name": "add_layout_legend"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | No | ||
| y | No | ||
| title | No | Legend | |
| width | No | ||
| height | No | ||
| layer_ids | No | ||
| layout_name | Yes | ||
| map_item_id | No |