The Legend item is a box or a table that explains the meanings of the symbols used on the map. A legend is then bound to a map item. You can add a legend item with the Add Legend tool following items creation instructions and manipulate it the same way as exposed in Interacting with layout items.
By default, the legend item displays all available layers and can be refined using its Item Properties panel. Other than the items common properties, this feature has the following functionalities (see figure_layout_legend):
The Main properties group of the legend Item Properties panel provides the following functionalities (see figure_layout_legend_ppt):
În proprietățile principale puteți:
change the title of the legend. It can be made dynamic using the data-defined override setting, useful for example when generating atlas;
set the Title alignment to Left, Center or Right;
choose which Map item the current legend will refer to;
wrap the text of the legend on a given character: each time the character appears, it’s replaced by a line break;
use Resize to fit contents to control whether or not a legend should be automatically resized to fit its contents. If unchecked, then the legend will never resize and instead just stick to whatever size the user has set. Any content which doesn’t fit the size is cropped out.
The Legend items group of the legend Item Properties panel provides the following functionalities (see figure_layout_legend_items):
The legend will be updated automatically if Auto-update is checked. When Auto-update is unchecked this will give you more control over the legend items. The icons below the legend items list will be activated.
The legend items window lists all legend items and allows you to change item order, group layers, remove and restore items in the list, edit layer names and add a filter.
The Filter legend by expression helps you filter which of the legend items of a layer will be displayed, i.e. using a layer that has different legend items (e.g., from a rule-based or categorized symbology), you can specify a boolean expression to remove from the legend tree, styles that have no feature satisfying a condition. Note that the features are nevertheless kept and shown in the layout map item.
While the default behavior of the legend item is to mimic the Layers panel tree, displaying the same groups, layers and classes of symbology, right-click any item offers you options to hide layer’s name or raise it as a group or subgroup. In case you have made some changes to a layer, you can revert them by choosing Reset to defaults from the contextual menu.
After changing the symbology in the QGIS main window, you can click on Update All to adapt the changes in the legend element of the print layout.
The Fonts, Columns and Symbol groups of the legend Item Properties panel provide the following functionalities (see figure_layout_legend_fonts):
You can change the font of the legend title, group, subgroup and item (feature) in the legend item using the font selector widget;
You provide the labels with a Color using the color selector widget. The selected color will apply to all font items in the legend;
You can also change the width and height of the legend symbol, set a color and a thickness in case of raster layer symbol.
The WMS LegendGraphic and Spacing groups of the legend Item Properties panel provide the following functionalities (see figure_layout_legend_wms):
When you have added a WMS layer and you insert a legend item, a request will be sent to the WMS server to provide a WMS legend. This Legend will only be shown if the WMS server provides the GetLegendGraphic capability. The WMS legend content will be provided as a raster image.
WMS LegendGraphic is used to be able to adjust the Legend width and the Legend height of the WMS legend raster image.
Spacing around title, group, subgroup, symbol, icon label, box, column or line can be customized through this dialog.