Manual range selection for graduated style vector layer in QGIS?
Finally I found a solution. As it is not possible to adjust the limits of color range manually, it is at least possible to set the ranges of every class manually. Instead of doing this again and again for every profile, it is then possible to save it and just load the style in other projects. Within the same project it is even possible to copy and paste the styles from other profiles.
Seems to be impossible to do automatically in Graduated
style, but here is a workaround by setting the color with an expression:
Select a Single symbol
style. Go to Simple fill
under Fill
, and open the expression editor of Fill
color. Enter this:
ramp_color('RdBu', scale_linear(DH, <lowerbound>, <upperbound>, 0, 1) )
'RdBu' is the gradient's name (red to blue in this case), <lowerbound> and <upperbound> are the limits.
If you want to have zero to be at the the middle of the gradient, just set the upper and lower bounds to be the same (-x...+x). To do it automatically:
ramp_color('RdBu', scale_linear(DH, min(minimum(DH),-maximum(DH)), max(maximum(DH),-minimum(DH)), 0, 1 ) )
(Putting an expression in Column
of Graduated
style is no good for centering zero: whatever comes out from that expression, the classifier doesn't know where zero is.)