Is it possible to label a layer using same colors as the categorized symbology of that layer?

It is possible using the Rule-based labeling, but it can be difficult for a layer with many categories and maybe it can be done using the Data-defined override, but I don't know how to get the color used for every category.


Using QGIS 3.4.5, you can write @symbol_color in the data defined override for coloring the text:

  1. Go to Data defined override -> Edit

enter image description here

  1. Write the following:


enter image description here

  1. Use buffer around the text to see the label
  2. Output:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.