I recently looked at some other posts relating 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).
Use the TopoColour plugin, which is already compatible with QGIS 2.x but is not yet available in the official repository:
Download the zip file and unzip it in the QGIS plugin directory:
Alternatively, pick up the new 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
I know that the question is about QGIS 2 but I'll add the answer for QGIS 3 because I kept coming back to question while looking for it.
It is now 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.