Menu

1 / 2

Building a US choropleth in Python with plotly express, using a real fragrance dataset

DEV Community·ahmad-khan-97·6 months ago
#w9tFEZtA
#python#dataviz#state#plotly#states
Reading 0:00
15s threshold

Plotly Express's choropleth is one of the cleanest "low-code, high-output" data viz tools in the Python ecosystem, but the documentation skips a few non-obvious gotchas that bite you the first time you build a US-state-level map. This walkthrough builds a publication-grade state map end-to-end, using a real dataset I open-sourced last week.

The dataset: the most-searched fragrance in every US state over the last 12 months, pulled from Google Trends across 30 of the most-talked-about fragrances of 2024-2026. Full dataset on GitHub under CC BY 4.0 , full written analysis at perfumem.com .

What you'll build

A US state choropleth where each state is colored by its category winner (a discrete, not continuous, value), with a clean legend and a high-DPI export that's safe to drop into a blog post or report.

Setup

pip install plotly pandas kaleido

Enter fullscreen mode

Exit fullscreen mode

kaleido is the static image export engine; you need it if you want PNG output instead of just an interactive HTML…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.