[GIS] Change font size of label with data defined expression in QGIS

labelingqgis

I am trying to change the font size of the feature labels based on attributes from a field. I can't find an example of how to do this.

I believe I can do this by setting up a data defined expression in the Labels>Text>Size expression but I am not sure how to formulate the actual expression.

I am looking for an example of how this expression would be set up.

Best Answer

Firstly, go on the Layer Properties > Labels > Text window.

Then, edit the expression for the text size (I marked it in the image below):

enter image description here

In the expression field, simply write the name of the field which stores the sizes for the fonts of the labels. In my case, the field was called font_height, so I wrote (remember to use these " "):

enter image description here

Finally, click on the Apply button and this will be the result:

enter image description here

Related Question