5

I have a set of polygons with two variables "variable 1" which can take values A, B, C, D, and E and "variable 2" which can take values V, W, X, Y and Z.

I would want to render the polygon by the crosstabulation of these two variables. So the legend might look something like this:

Representation of a cross tabulated legend

I could do it by concatenating variable 1 and variable 2 and individually specifying the 25 colours, but I wonder if there is a more elegant solution already implemented in QGIS?

2
  • 1
    Have you seen this thread before: gis.stackexchange.com/questions/315340/… ?
    – Taras
    Commented Jun 25 at 8:24
  • Use a similar technique to that link, have the A-E layer coloured as per your palette, and above that the V-Z coloured grayscale, then set the blending mode so that V-Z modifies the base colour.
    – Spacedman
    Commented Jun 25 at 9:36

1 Answer 1

9

We can achieve this by combining Categorized symbols based on 'Variable 1' with color lightness based on 'Variable 2'.

enter image description here

Categorize symbols based on 'Variable 1' as follows:

enter image description here

Then select each colour and apply an expression to each fill colour as follows. 'Variable 2' is used to adjust the lightness of the colour:

enter image description here

enter image description here

 CASE 
    WHEN  "Variable 2" = 'V' THEN lighter( @symbol_color, 125)
    WHEN  "Variable 2" = 'W' THEN lighter( @symbol_color, 150)
    WHEN  "Variable 2" = 'X' THEN lighter( @symbol_color, 175)
    WHEN  "Variable 2" = 'Y' THEN lighter( @symbol_color, 200)
    WHEN  "Variable 2" = 'Z' THEN lighter( @symbol_color, 225)
 END
3
  • 1
    Elegant. Just for further explanation. The values in the function set the translucent levels. That ranges from 0 to 255. Commented Jun 25 at 20:55
  • 1
    Thank you. I believe lighter() sets the brightness not the translucent level (transparency). docs.qgis.org/3.34/en/docs/user_manual/expressions/…
    – Cushen
    Commented Jun 25 at 23:23
  • Ha! My mistake. I thought this was setting the A value for RGBA. Commented Jul 1 at 5:29

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.