I use QGIS to create surface plots for measurements made in the field. I use the contour plugin. I usually create ~50 contours in order to make a smooth surface. When I use print composer, I generally go in and remove most of the legend items so the legend isn't too large to fit. This is tedious and I'm working on a report with many (50+) plots... I want to do a conditional format. Something like divide the largest value by 10, then use only variables in the 10 "bins".

The issue is that I can't figure out how to "index" the individual values within the legend. If I select the legend item of interest (the contour grid values), then use expression builder, I seem to only be able to "index" one item in the legend (for instance, "symbol_count" is 1 and the "symbol_label" is only the first label in the legend. Here is an example:

conditional formatting

I'm hoping there is some way to represent the entire value range within the legend as a variable so I would be able to work with the values, pare them down to ~10, then have them represented in the legend without so much clutter (or having to manually edit). Are there any legend experts that can help me identify a variable that represents the numbers vector for my legend(s)?

1 Answer 1


Not so much a legend expert and not sure if it is still relevant, but here is what I would do. you could duplicate the layer and classify that one with only 10 classes instead of the 50 you have now. Then don't show that layer on the map but base the legend on it. Since it is the same data, you can make the color scale exactly the same. You can also do more fancy stuff like rounding your data, adding units etc. in the symbology tab of the layer properties. additionally, if your 50+ plots all have the same data range, you only have to do this once, and you could use the same legend over and over.

Is this something that could work?

  • 1
    Wow - thanks for an answer. I did it all manually back in March, but will have another report to do in the not too distant future. Will give it a try. Great idea! Will post back if I get something working along those lines. Commented Dec 4, 2020 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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