7

I use rule-based styling in QGIS, in order to do spatial quantile, computed in R. If I want to change the color ramp, I need to either: change every class color, or set graduated then change the color ramp and go back to rule-based and re-enter my classes thresholds.

Is there a way to change the color ramp for a rule-based styling directly into the rule-based panel ?

1 Answer 1

1

You can define the filling of a single symbol as a color ramp, defined by data values.

Edit your symbology, click the drop-down list data defined override (on the right of the color menu) and click on "edit" to define a color by expression, for exemple:

CASE 
WHEN "attribute" < 0 THEN 'red'
WHEN "attribute" > 100 THEN 'blue'
ELSE 'yellow'
END

You can also use the assistant in the same drop-down menu to define your threshold with an attribute or an expression and the value ramp associated. This will define the color with a color-ramp expression like this:

coalesce(ramp_color('custom ramp',scale_linear("attribute", 0, 9, 0, 1)), '#000000')

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.