Skip to content
OpenChart

Colorblind-safe chart palettes for light and dark mode

Charts that rely on red against green fail for readers with color vision deficiency. This post covers palettes that work in light and dark mode.

20162017201820192020202120222023010203040Share of generation (%)CoalGasNuclearHydroWindSolarGas rose to 43.5% in 2023 and coal fell to 16.2%Share of US electricity from the six main sources (%), 2016-202320162017201820192020202120222023010203040Share of generation (%)CoalGasNuclearHydroWindSolarGas rose to 43.5% in 2023 and coal fell to 16.2%Share of US electricity from the six main sources (%), 2016-2023
US electricity mix with gas and coal highlighted in Okabe-Ito colors. Source: Our World in Data (owid/electricity-mix).

Made with OpenChart. How to build this line chart

Roughly 1 in 12 men of Northern European descent has red-green color vision deficiency, which collapses red and green hues into similar yellow-brown tones. Any chart that relies on a red-green pair for positive and negative bars or two competing lines erases that distinction for those readers. Converting a draft chart to grayscale catches most palette failures immediately, because two colors that differ only in hue flatten into the same shade of gray.

Luminance, the perceived brightness of a color, is the channel that survives both color vision deficiency and monochrome printing. Deuteranopia (reduced green sensitivity) and protanopia (reduced red sensitivity) distort how hues look while leaving brightness differences intact. Building a palette around lightness contrast first, then picking hues that stay apart under both conditions, gives every reader the same visual order.

Highlighting two series

Assigning six bright hues to six lines forces readers to jump back and forth between the plot and a legend while trying to tell medium green apart from orange or teal. Even with full color vision, most people hold only three or four distinct hues in working memory at once. When a chart centers on one comparison, giving every line equal visual weight hides the main change behind four competing colors.

Focusing two lines in high-contrast hues and muting the rest to neutral gray makes the comparison legible in color and in grayscale. Gas and coal drove the main shift in US electricity generation from 2016 to 2023, so gas takes deep blue and coal takes vermilion from the Okabe-Ito colorblind-safe palette. That blue-orange pair stays distinct across red-green and blue-yellow deficiencies, and thicker strokes separate both lines from the four muted gray sources.

Direct endpoint labels place each source name right beside its line and remove the legend altogether. Readers can identify every series without matching a colored swatch to a stroke, even where hydro and solar finish tied at 5.8% in 2023.

20162017201820192020202120222023010203040Share of generation (%)CoalGasNuclearHydroWindSolarGas rose to 43.5% in 2023 and coal fell to 16.2%Share of US electricity from the six main sources (%), 2016-202320162017201820192020202120222023010203040Share of generation (%)CoalGasNuclearHydroWindSolarGas rose to 43.5% in 2023 and coal fell to 16.2%Share of US electricity from the six main sources (%), 2016-2023
Live example. Source: Our World in Data (owid/electricity-mix).

Made with OpenChart. How to build this line chart

{
  "mark": {
    "type": "line",
    "strokeWidth": 2
  },
  "data": [
    {
      "year": "2016",
      "source": "Coal",
      "share": 31.2
    },
    {
      "year": "2016",
      "source": "Gas",
      "share": 34.8
    },
    {
      "year": "2016",
      "source": "Nuclear",
      "share": 20.3
    },
    {
      "year": "2016",
      "source": "Hydro",
      "share": 6.6
    },
    {
      "year": "2016",
      "source": "Wind",
      "share": 5.7
    },
    {
      "year": "2016",
      "source": "Solar",
      "share": 1.4
    },
    // … 42 more rows; Copy includes them
  ],
  "encoding": {
    "x": {
      "field": "year",
      "type": "temporal",
      "axis": {
        "format": "%Y",
        "tickCount": 8
      }
    },
    "y": {
      "field": "share",
      "type": "quantitative",
      "axis": {
        "title": "Share of generation (%)",
        "format": ".0f",
        "grid": true
      }
    },
    "color": {
      "field": "source",
      "type": "nominal",
      "scale": {
        "domain": [
          "Gas",
          "Coal",
          "Nuclear",
          "Wind",
          "Hydro",
          "Solar"
        ],
        "range": [
          "#0072b2",
          "#d55e00",
          "#7a858f",
          "#7a858f",
          "#7a858f",
          "#7a858f"
        ]
      }
    }
  },
  "legend": {
    "show": false
  },
  "endpointLabels": {
    "content": "label"
  },
  "seriesStyles": {
    "Gas": {
      "strokeWidth": 3
    },
    "Coal": {
      "strokeWidth": 3
    }
  },
  "chrome": {
    "title": "Gas rose to 43.5% in 2023 and coal fell to 16.2%",
    "subtitle": "Share of US electricity from the six main sources (%), 2016-2023"
  },
  "overrides": {
    "compact": {
      "encoding": {
        "x": {
          "axis": {
            "values": [
              "2016",
              "2020",
              "2023"
            ]
          }
        }
      }
    },
    "medium": {
      "encoding": {
        "x": {
          "axis": {
            "values": [
              "2016",
              "2020",
              "2023"
            ]
          }
        }
      }
    }
  }
}
import { Chart } from "@opendata-ai/openchart-react";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";

const data = [/* 48 rows; Copy includes them */];

const spec: ChartSpec = {
  data,
  "mark": {
    "type": "line",
    "strokeWidth": 2
  },
  "encoding": {
    "x": {
      "field": "year",
      "type": "temporal",
      "axis": {
        "format": "%Y",
        "tickCount": 8
      }
    },
    "y": {
      "field": "share",
      "type": "quantitative",
      "axis": {
        "title": "Share of generation (%)",
        "format": ".0f",
        "grid": true
      }
    },
    "color": {
      "field": "source",
      "type": "nominal",
      "scale": {
        "domain": [
          "Gas",
          "Coal",
          "Nuclear",
          "Wind",
          "Hydro",
          "Solar"
        ],
        "range": [
          "#0072b2",
          "#d55e00",
          "#7a858f",
          "#7a858f",
          "#7a858f",
          "#7a858f"
        ]
      }
    }
  },
  "legend": {
    "show": false
  },
  "endpointLabels": {
    "content": "label"
  },
  "seriesStyles": {
    "Gas": {
      "strokeWidth": 3
    },
    "Coal": {
      "strokeWidth": 3
    }
  },
  "chrome": {
    "title": "Gas rose to 43.5% in 2023 and coal fell to 16.2%",
    "subtitle": "Share of US electricity from the six main sources (%), 2016-2023"
  },
  "overrides": {
    "compact": {
      "encoding": {
        "x": {
          "axis": {
            "values": [
              "2016",
              "2020",
              "2023"
            ]
          }
        }
      }
    },
    "medium": {
      "encoding": {
        "x": {
          "axis": {
            "values": [
              "2016",
              "2020",
              "2023"
            ]
          }
        }
      }
    }
  }
};

export function Example() {
  return <Chart spec={spec} />;
}
<script setup lang="ts">
import { Chart } from "@opendata-ai/openchart-vue";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";

const data = [/* 48 rows; Copy includes them */];

const spec: ChartSpec = {
  data,
  "mark": {
    "type": "line",
    "strokeWidth": 2
  },
  "encoding": {
    "x": {
      "field": "year",
      "type": "temporal",
      "axis": {
        "format": "%Y",
        "tickCount": 8
      }
    },
    "y": {
      "field": "share",
      "type": "quantitative",
      "axis": {
        "title": "Share of generation (%)",
        "format": ".0f",
        "grid": true
      }
    },
    "color": {
      "field": "source",
      "type": "nominal",
      "scale": {
        "domain": [
          "Gas",
          "Coal",
          "Nuclear",
          "Wind",
          "Hydro",
          "Solar"
        ],
        "range": [
          "#0072b2",
          "#d55e00",
          "#7a858f",
          "#7a858f",
          "#7a858f",
          "#7a858f"
        ]
      }
    }
  },
  "legend": {
    "show": false
  },
  "endpointLabels": {
    "content": "label"
  },
  "seriesStyles": {
    "Gas": {
      "strokeWidth": 3
    },
    "Coal": {
      "strokeWidth": 3
    }
  },
  "chrome": {
    "title": "Gas rose to 43.5% in 2023 and coal fell to 16.2%",
    "subtitle": "Share of US electricity from the six main sources (%), 2016-2023"
  },
  "overrides": {
    "compact": {
      "encoding": {
        "x": {
          "axis": {
            "values": [
              "2016",
              "2020",
              "2023"
            ]
          }
        }
      }
    },
    "medium": {
      "encoding": {
        "x": {
          "axis": {
            "values": [
              "2016",
              "2020",
              "2023"
            ]
          }
        }
      }
    }
  }
};
</script>

<template>
  <Chart :spec="spec" />
</template>
<script lang="ts">
import { Chart } from "@opendata-ai/openchart-svelte";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";

const data = [/* 48 rows; Copy includes them */];

const spec: ChartSpec = {
  data,
  "mark": {
    "type": "line",
    "strokeWidth": 2
  },
  "encoding": {
    "x": {
      "field": "year",
      "type": "temporal",
      "axis": {
        "format": "%Y",
        "tickCount": 8
      }
    },
    "y": {
      "field": "share",
      "type": "quantitative",
      "axis": {
        "title": "Share of generation (%)",
        "format": ".0f",
        "grid": true
      }
    },
    "color": {
      "field": "source",
      "type": "nominal",
      "scale": {
        "domain": [
          "Gas",
          "Coal",
          "Nuclear",
          "Wind",
          "Hydro",
          "Solar"
        ],
        "range": [
          "#0072b2",
          "#d55e00",
          "#7a858f",
          "#7a858f",
          "#7a858f",
          "#7a858f"
        ]
      }
    }
  },
  "legend": {
    "show": false
  },
  "endpointLabels": {
    "content": "label"
  },
  "seriesStyles": {
    "Gas": {
      "strokeWidth": 3
    },
    "Coal": {
      "strokeWidth": 3
    }
  },
  "chrome": {
    "title": "Gas rose to 43.5% in 2023 and coal fell to 16.2%",
    "subtitle": "Share of US electricity from the six main sources (%), 2016-2023"
  },
  "overrides": {
    "compact": {
      "encoding": {
        "x": {
          "axis": {
            "values": [
              "2016",
              "2020",
              "2023"
            ]
          }
        }
      }
    },
    "medium": {
      "encoding": {
        "x": {
          "axis": {
            "values": [
              "2016",
              "2020",
              "2023"
            ]
          }
        }
      }
    }
  }
};
</script>

<Chart {spec} />
import { createChart } from "@opendata-ai/openchart-vanilla";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";

const data = [/* 48 rows; Copy includes them */];

const spec: ChartSpec = {
  data,
  "mark": {
    "type": "line",
    "strokeWidth": 2
  },
  "encoding": {
    "x": {
      "field": "year",
      "type": "temporal",
      "axis": {
        "format": "%Y",
        "tickCount": 8
      }
    },
    "y": {
      "field": "share",
      "type": "quantitative",
      "axis": {
        "title": "Share of generation (%)",
        "format": ".0f",
        "grid": true
      }
    },
    "color": {
      "field": "source",
      "type": "nominal",
      "scale": {
        "domain": [
          "Gas",
          "Coal",
          "Nuclear",
          "Wind",
          "Hydro",
          "Solar"
        ],
        "range": [
          "#0072b2",
          "#d55e00",
          "#7a858f",
          "#7a858f",
          "#7a858f",
          "#7a858f"
        ]
      }
    }
  },
  "legend": {
    "show": false
  },
  "endpointLabels": {
    "content": "label"
  },
  "seriesStyles": {
    "Gas": {
      "strokeWidth": 3
    },
    "Coal": {
      "strokeWidth": 3
    }
  },
  "chrome": {
    "title": "Gas rose to 43.5% in 2023 and coal fell to 16.2%",
    "subtitle": "Share of US electricity from the six main sources (%), 2016-2023"
  },
  "overrides": {
    "compact": {
      "encoding": {
        "x": {
          "axis": {
            "values": [
              "2016",
              "2020",
              "2023"
            ]
          }
        }
      }
    },
    "medium": {
      "encoding": {
        "x": {
          "axis": {
            "values": [
              "2016",
              "2020",
              "2023"
            ]
          }
        }
      }
    }
  }
};

const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);

Sequential scales and dark mode

Ordered numeric data, such as state unemployment rates, needs a sequential scale that steps steadily from light to dark within one hue. Rainbow scales break that order because yellow looks brighter than neighboring green and blue and creates false bands across smooth data. A single-hue blue ramp maps low values to pale tints and high values to deep shades, so every reader sees the same ranking in color or grayscale.

Dark mode changes how every palette reads because dark surfaces make saturated colors glare and swallow dark strokes. Blindly inverting raw hex codes turns muted shades into harsh neons and breaks text contrast on filled tiles. Well-tuned dark themes lift categorical colors to higher lightness against dark backgrounds and reverse sequential ramps so high values glow brightest while tile labels switch ink for contrast.

Across US states and DC in the Bureau of Labor Statistics snapshot, unemployment runs from 2.3% in South Dakota to 5.7% in DC. Switching between light and dark mode preserves that single-hue order while adapting both the ramp direction and the label contrast inside every tile.

State unemployment runs from 2.3% in South Dakota to 5.7% in DCUS state unemployment rate, seasonally adjusted (%)ME3.3VT2.6NH3.0WA5.1ID3.6MT3.6ND2.8MN4.9WI4.0MI5.1NY4.4MA4.7OR5.2NV5.1WY3.8SD2.3IA3.3IL5.1IN3.6OH4.0PA4.2NJ4.9CT4.8CA5.3UT3.8CO3.8NE3.1MO4.2KY4.2WV4.5VA3.8MD4.3DE5.4RI4.9AZ4.7NM4.8KS3.8AR4.2TN3.3NC3.7SC4.2DC5.7AK4.8OK3.9LA4.4MS3.8AL2.7GA3.5HI2.4TX4.3FL4.42.35.7State unemployment runs from 2.3% in South Dakota to 5.7% in DCUS state unemployment rate, seasonally adjusted (%)ME3.3VT2.6NH3.0WA5.1ID3.6MT3.6ND2.8MN4.9WI4.0MI5.1NY4.4MA4.7OR5.2NV5.1WY3.8SD2.3IA3.3IL5.1IN3.6OH4.0PA4.2NJ4.9CT4.8CA5.3UT3.8CO3.8NE3.1MO4.2KY4.2WV4.5VA3.8MD4.3DE5.4RI4.9AZ4.7NM4.8KS3.8AR4.2TN3.3NC3.7SC4.2DC5.7AK4.8OK3.9LA4.4MS3.8AL2.7GA3.5HI2.4TX4.3FL4.42.35.7
US state unemployment rate on a single-hue blue scale. Source: Bureau of Labor Statistics, Local Area Unemployment Statistics.

Made with OpenChart. How to build this tile map

{
  "type": "tilemap",
  "data": {
    "AL": 2.7,
    "AK": 4.8,
    "AZ": 4.7,
    "AR": 4.2,
    "CA": 5.3,
    "CO": 3.8,
    "CT": 4.8,
    "DE": 5.4,
    "DC": 5.7,
    "FL": 4.4,
    "GA": 3.5,
    "HI": 2.4,
    "ID": 3.6,
    "IL": 5.1,
    "IN": 3.6,
    "IA": 3.3,
    "KS": 3.8,
    "KY": 4.2,
    "LA": 4.4,
    "ME": 3.3,
    "MD": 4.3,
    "MA": 4.7,
    "MI": 5.1,
    "MN": 4.9,
    "MS": 3.8,
    "MO": 4.2,
    "MT": 3.6,
    "NE": 3.1,
    "NV": 5.1,
    "NH": 3,
    "NJ": 4.9,
    "NM": 4.8,
    "NY": 4.4,
    "NC": 3.7,
    "ND": 2.8,
    "OH": 4,
    "OK": 3.9,
    "OR": 5.2,
    "PA": 4.2,
    "RI": 4.9,
    "SC": 4.2,
    "SD": 2.3,
    "TN": 3.3,
    "TX": 4.3,
    "UT": 3.8,
    "VT": 2.6,
    "VA": 3.8,
    "WA": 5.1,
    "WV": 4.5,
    "WI": 4,
    "WY": 3.8
  },
  "palette": "blue",
  "valueFormat": ".1f",
  "chrome": {
    "title": "State unemployment runs from 2.3% in South Dakota to 5.7% in DC",
    "subtitle": "US state unemployment rate, seasonally adjusted (%)"
  }
}
import { TileMap } from "@opendata-ai/openchart-react";
import type { TileMapSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";

const spec: TileMapSpec = {
  "type": "tilemap",
  "data": {/* 51 entries, as in the Spec tab; Copy includes them */},
  "palette": "blue",
  "valueFormat": ".1f",
  "chrome": {
    "title": "State unemployment runs from 2.3% in South Dakota to 5.7% in DC",
    "subtitle": "US state unemployment rate, seasonally adjusted (%)"
  }
};

export function Example() {
  return <TileMap spec={spec} />;
}
<script setup lang="ts">
import { TileMap } from "@opendata-ai/openchart-vue";
import type { TileMapSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";

const spec: TileMapSpec = {
  "type": "tilemap",
  "data": {/* 51 entries, as in the Spec tab; Copy includes them */},
  "palette": "blue",
  "valueFormat": ".1f",
  "chrome": {
    "title": "State unemployment runs from 2.3% in South Dakota to 5.7% in DC",
    "subtitle": "US state unemployment rate, seasonally adjusted (%)"
  }
};
</script>

<template>
  <TileMap :spec="spec" />
</template>
<script lang="ts">
import { TileMap } from "@opendata-ai/openchart-svelte";
import type { TileMapSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";

const spec: TileMapSpec = {
  "type": "tilemap",
  "data": {/* 51 entries, as in the Spec tab; Copy includes them */},
  "palette": "blue",
  "valueFormat": ".1f",
  "chrome": {
    "title": "State unemployment runs from 2.3% in South Dakota to 5.7% in DC",
    "subtitle": "US state unemployment rate, seasonally adjusted (%)"
  }
};
</script>

<TileMap {spec} />
import { createTileMap } from "@opendata-ai/openchart-vanilla";
import type { TileMapSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";

const spec: TileMapSpec = {
  "type": "tilemap",
  "data": {/* 51 entries, as in the Spec tab; Copy includes them */},
  "palette": "blue",
  "valueFormat": ".1f",
  "chrome": {
    "title": "State unemployment runs from 2.3% in South Dakota to 5.7% in DC",
    "subtitle": "US state unemployment rate, seasonally adjusted (%)"
  }
};

const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createTileMap(container, spec);

The spec

Code under the electricity chart opens its spec. In encoding.color, scale.domain lists all six sources in a fixed order so scale.range assigns deep blue (#0072b2) to Gas, vermilion (#d55e00) to Coal, and neutral gray (#7a858f) to the remaining four. seriesStyles raises the focus stroke width to three pixels, while legend: { show: false } and endpointLabels: { content: "label" } place each series name at the end of its line.

On a phone, the compact and medium blocks in overrides (charts under 700 pixels wide) set the x axis ticks to 2016, 2020 and 2023, so the first and last years still show beside the labels.

On the tile map, palette: "blue" picks OpenChart’s sequential ramp, which adjusts automatically when the host passes darkMode: "force" or darkMode: "auto". When a chart must hit exact brand colors in both themes, any slot in theme.colors (including each entry in theme.colors.categorical) accepts a { light, dark } object instead of one string. Supplying a darker shade for light and a lifted shade for dark locks contrast on both backgrounds while bypassing automatic derivation.

For built-in color schemes and grayscale print patterns, see the color palettes guide.