Four color theorem for QGIS? (4 colour)

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.

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

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 COLORID field:

enter image description here