[GIS] How to group elements in QGIS legend side by side

legendqgis

I would like to edit the legend in my map so that the entries of two polygons will appear together, i.e. the two entries in the legend should be displayed appear as "Study area and possible study area" as two elements side by side.
Is there a possibility to group the symbols in such a way?

Study Area and possible study area

 _ _   _ _
|_ _| |_ _|

Best Answer

Assuming that you wish to do this in a QGIS Print Composer layout, and not the main interface's layer legend (which is currently not possible), here is a layout representation of what you may be looking for:

enter image description here

Note that this legend is comprised of multiple items (not just a basic legend item): background rectangle, title label and two legend items (in stacking order bottom to top). You can have multiple legends in your Composer layout, and you can control whether they have a title, which the two in this layout do not, and what layers are shown.

You will have to manually select the layers you want for each 'column' and synchronize several legend item properties between legend items to get this to work well. Set the Opacity for the background of the legends to 0 and make sure the fonts match between legends.

Couple of notes: whenever you edit certain aspects of a legend item, like showing or hiding layers, the Composer will auto-shrink the legend item's bounding box, which is (mostly) a feature. This may cause problems if you are using anything but the left and top borders of a legend item in an alignment operation.

Basically, with this method, you can have as many 'columns' as you want, but each one requires an initial manual setup. Further maintenance will be required upon adding new layers to your project, as those layers will be auto-added to each legend 'column'. You can turn this behavior off by un-checking the Auto Update option under the Legend Items panel.

There is no function in Composer, as of yet, to auto-create columns.

Related Question