I am using QGIS right now to create an election swing map. This is different from a usual election map in that it measures differences in winning margins from one election to another. For example, Joe Biden could have won a precinct by 100 points in 2020, after Trump beat Clinton in that same precinct by 100 points. That would be a swing of D+200.

Well, even though D/R+200 is the maximum possible swing, some precincts never reach that level. This complicates my graduated classes.

I am using red to show a Republican shift, blue to show a Democratic shift, and white to show no shift at all. However, because the maximum shift to the Republicans is R+200 and the maximum shift to the Democrats is only D+150, this makes an unbalanced scale. A +0 shift is now on the red side of the color scale, when it absolutely needs to be clear white.

I have used all the other modes (equal interval, logarithmic, etc.), and none are able to create the color scale I want. I'd like to make 999 classes, separated equally, only that after D/R+100, it would go on to infinity.

Above, this scale is what I am aiming for, but I'd like it to be "-INFINITY - 99.799800," with the same on the Democratic/blue side of the scale. This way, the scale would be even with +0 being white, and any swing above D/R+100 would be capped off.

  • 3
    One solution would be to add an "non geometry" entry in your attribut table of +200 for Democrats.
    – katagena
    Commented Jun 14, 2022 at 6:29

2 Answers 2


You have a range from -200 to 150 and you want the white color to be at 0. In your color ramp, white is at 50%, thus exactly in the middle - thus for your range of values at -25 (mean of -200 and 150).

So what you can do is shifting the white tab of your color ramp to the right. In the range from -200 to 150, 0 is at 57.14% (200/150*100) of the total range. So click on the color ramp, select the tab of the white color and manually change its relative position to 57.1%.

enter image description here

Consider deleting all the other color position tabs (except the first/left/red one and the last/right/blue one) to get a continuous color ramp.

All but the first, middle and last tab deleted: enter image description here

  • 1
    Thank you, thank you, thank you! I was also able to add two more arrows to the color scale so that D/R+20 would be the maximum red, effectively capping it there. I don't know if that makes sense to you, but this is exactly what I needed. You have to do a little bit of math, but it makes the map much more informative and intuitive to the eye, so I don't mind. Commented Jun 14, 2022 at 19:46

Another simple solution would be to use the Assistant in your Fill color.

This sample layer has a field with values from -200 to 150. As you can see, a normal graduated symbology would output your same results:

enter image description here

Instead, you can just symbolize using Single Symbol and use the Assistant to modify your Fill Color:

enter image description here

From here you can populate the min - max values as you need them to be, the scale is independent from your values. In your case, you want a range from -200 to 200:

enter image description here

You can do this even if there are no values from 150 to 200. Make sure to not apply any transformation curves since you want a linear scale.

  • 1
    Tag: applying continuous colour ramp to vector points by attribute instead of individual graduated classes in QGIS (helpful, thanks)
    – Buff Fox
    Commented Nov 23, 2022 at 23:00

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.