I recently looked at Applying four colors theorem in polygon map using ArcMap which relates to this topic but as far as I can tell there is currently not a working plugin or script for QGIS 2.0 to achieve a four color theorem for styling polygon vector data (it doesn't necessarily have to be 4 colors, just so that each neighboring polygon is a different color, though keeping it at a minimum number of 4-6 colors would be elegant).
3 Answers
This is natively supported in QGIS 3.
- View → Panels → Processing Toolbox
- Select Topological coloring
- Set parameters as preferred. Run.
- This will create a new layer with an additional color_id column but still the same color.
- Edit the properties of the new layer, Symbology section.
- At the top, drop down to select Categorized.
- Define the column as color_id.
- Select your color scheme.
- Click Classify to create the categories and assign them the colors.
-
1As of Qgis 3.26 this does not necessarily achieve 4 colors. In my first test using the counties of NM as the input layer, the algorithm required 5 colors regardless of parameter choices.– LlavesCommented Feb 22, 2023 at 16:24
-
@Llaves, I did check my own maps and got the exact same result with older and latest versions of QGIS. I initially tried a map that required 6 colors but it was the same with the older version of QGIS and it seems that it was required. Commented Feb 26, 2023 at 19:59
You could try the Map Coloring plugin. You need to enable experimental plugins in the Plugin manager to get it, and look for Coloring a map
in the manager. For some strange reasons, you get a blank icon, so use Plugins -> Map Coloring -> Map Coloring
from the menu.
The output looks like this, after switching to Categorized
styling on the COLORID
field:
Use the TopoColour plugin, which is already compatible with QGIS 2.x but is not yet available in the official repository:
https://github.com/nyalldawson/topocolour
Download the zip file and unzip it in the QGIS plugin directory:
- Linux:
~/.qgis2/python/plugins
- Windows:
C:\Users\{username}\.qgis2\python\plugins