QGIS – Changing Justification of Legend Symbol Text Set from ‘Set Labels from Expression…’

legendqgissymbologytext;

In QGIS, I have a polygon layer with several text column attributes. I am theming on one, but want the text of another column to show up in the legend. I have successfully populated the text column using the "set labels from Expression…" dialogue from the layer properties legend window as per image1…

enter image description here

But in the actual legend in layout view, the text only shows up as center justified and there is no apparent way to set it to left justify, so that it does not overlap with the symbols (image2).

enter image description here

I've tried changing the text alignment attributes in the layout-legend-Fonts and text panel, but none of the four options there affect the text attribute column independently.

Best Answer

In the legend tab → Text on Symbol, you need to select the column that holds the lithology symbols, not the description (Lithology), and everything should work correctly:

  • Select label from expression and select the column in the attribute table that holds the symbols (code) of the lithology:

enter image description here

  • The lithology description should be loaded automatically when you style your layer based on the description column.:

enter image description here

  • Here is the output:

enter image description here

  • In the layout view, here is the output:

enter image description here