Best practices · Data and ML
Data Visualization Best Practices
Opens with creditsBest practices for charts and data visualizations, checked against the UK Government Analysis Function's chart and colour guidance, WCAG 2.2, and the matplotlib, Plotly and Vega-Lite documentation. It covers choosing the chart, encoding and clutter, color and accessibility, axes and scales, titles and annotation, dashboards and interactive charts, and how to avoid charts that mislead.
What you will learn
7 chapters · about 18 min
1Start from the question and choose the chartThe right chart follows from the message and the shape of the data. These practices pick a chart type before any styling happens.4 practices · 3 min
2Encoding and clutterEvery mark, color and line on a chart should carry information. These practices remove what does not and make what does easy to read.4 practices · 2 min
- Color and accessibilityColor is powerful and easy to misuse. These practices pick color by data type, meet WCAG contrast rules and make sure no one depends on color alone.5 practices · 4 minOpens with credits
- Axes and scalesAxes decide how big a difference looks. These practices keep the visual size of a change in proportion to the real one.4 practices · 3 minOpens with credits
- Titles, annotation and contextA chart without context leaves readers to guess what matters. These practices put the message, the explanation and the source on the chart.4 practices · 2 minOpens with credits
- Dashboards and interactive chartsDashboards put many charts in front of busy people. These practices keep them focused, fast and usable by everyone.4 practices · 2 minOpens with credits
- Avoiding misleading chartsA chart can be built from correct numbers and still leave a false impression. These practices catch the common ways that happens.4 practices · 2 minOpens with credits
About this guide
A chart has one job: to help someone understand something about the data faster than they could from a table. Most bad charts fail that job in ordinary ways. The message is buried under a legend with eight colors. The bars start at 40, so a 5% difference looks like a doubling. Two lines that matter are red and green, and one reader in your audience cannot tell them apart. The title says "Revenue by month" when what you wanted people to notice is that revenue fell after the price change. These data visualization best practices are about avoiding those failures.
The guide leans on the UK Government Analysis Function's chart guidance, written for analysts who publish official statistics, and on the Web Content Accessibility Guidelines (WCAG) 2.2, the standard that public sector charts in many countries must meet. Code examples use matplotlib, Plotly and Vega-Lite, because each publishes detailed documentation and between them they cover static charts, interactive charts and declarative specs. The principles apply equally to Excel, Tableau, Power BI or D3.
Work through the chapters in order the first time. The first chapter starts with the question, not the chart type, because a chart chosen before you know your message is usually the wrong chart. The middle chapters cover the details that decide whether people can read it: encoding, color, axes and annotation. The last two cover dashboards and the ways a technically correct chart can still mislead.
Two habits are worth taking from this guide even if you read nothing else. Write your chart's message as one sentence before you draw it, and never let color be the only way to tell two things apart.
Common questions
Should a chart's y-axis always start at zero?
Bar charts should, because a bar shows a value as its length and a truncated axis distorts every comparison. Line charts show values by position, so zooming in can be honest when small changes matter, but mark any axis break, keep a sensible aspect ratio and say so in the text.
What colors should I use in charts for color blind readers?
Never make color the only difference: add direct labels, markers or line styles. Avoid red versus green as the key contrast, use perceptually uniform colormaps such as viridis or cividis for continuous data, and check the chart in grayscale. WCAG asks for 3:1 contrast for chart graphics and 4.5:1 for normal text.
When should I use a pie chart?
Rarely. UK Government Analysis Function guidance limits pie charts to part-to-whole data with five categories or fewer, ideally with one dominant share, labelled directly. For more categories or similar values, a sorted bar chart is easier to read.
Why are dual-axis charts considered misleading?
With two y-axes the author can choose both scales freely, so any two lines can be made to cross or move together. Use two charts with a shared x-axis, index both series to 100 at a common start date, or plot one measure against the other in a scatter plot.
What makes a good chart title?
A headline that states the main message, such as "Tickets halved after the new help centre launched", followed by a subtitle with what was measured, where and when. Put the source and extraction date in a note under the chart.
How do I make an interactive chart accessible?
Keep the message and key values visible without hovering, make all controls usable by keyboard with visible focus, provide a text description of the takeaway, and offer the data as a table or download. Test with keyboard and screen readers, since interactive charts often fail there.
Sources (8)
Checked against these, last on 13 October 2026.
- Data visualisation: charts, UK Government Analysis Functionanalysisfunction.civilservice.gov.uk/policy-store/data-visualisation-charts/
- Data visualisation: colours in charts, UK Government Analysis Functionanalysisfunction.civilservice.gov.uk/policy-store/data-visualisation-colours-in-charts/
- Data visualisation: testing dashboards for design and accessibility, UK Government Analysis Functionanalysisfunction.civilservice.gov.uk/policy-store/data-visualisation-testing-dashboards-for-design-and-accessibility
- Understanding Success Criterion 1.4.1: Use of Color, W3C WAIwww.w3.org/WAI/WCAG22/Understanding/use-of-color.html
- Understanding Success Criterion 1.4.11: Non-text Contrast, W3C WAIwww.w3.org/WAI/WCAG22/Understanding/non-text-contrast.html
- Choosing Colormaps in Matplotlib, matplotlib docsmatplotlib.org/stable/users/explain/colors/colormaps.html
- Scale, Vega-Lite docsvega.github.io/vega-lite/docs/scale.html
- Axes in Python, Plotly docsplotly.com/python/axes/
Related on Sefism
Picked from the other libraries by shared topics.
Roadmaps
See allCheat sheets
See allBest practices
See all- Data Pipeline Best PracticesHow to build data pipelines you can re-run, test and trust: idempotent tasks, orchestrator hygiene, layered transformations, data tests, freshness, ownership and monitoring.
- Data Analysis Best PracticesAn analyst's workflow in SQL, pandas and Polars: framing the question, reading data correctly, joins and grain, aggregation pitfalls, reproducible notebooks, checking results and sharing findings.
- Data Modeling Best PracticesDimensional data modeling for analytics: declaring the grain, fact and dimension tables, slowly changing dimensions, dbt marts, naming, tests, contracts and a semantic layer.
Checklists
See all- Data Quality ChecklistA data quality checklist for warehouse tables: ownership, freshness, volume, schema, nulls, uniqueness, referential checks, anomaly monitoring and data incidents, with how to verify each.
- Analytics Dashboard ChecklistAn analytics dashboard checklist for launch day: purpose and audience, metric definitions, data freshness, correctness, performance, access, accessibility, ownership and adoption.
- ML Model Deployment ChecklistAn ML model deployment checklist: baselines, training and serving consistency, validation, model registry, canary rollout, rollback, drift monitoring and ownership, with how to verify each.
Project structures
See all- dbt project project structureA dbt project that turns raw tables into tested, documented models, using the staging, intermediate and marts layers from dbt's own structure guide. It runs on DuckDB on your laptop, so you can learn analytics engineering for free, and grows into a governed project with checks, contracts, slim CI and a hosted docs site that moves to BigQuery or Snowflake unchanged.
- Apache Airflow project structureFor data engineers scheduling real pipelines with Airflow 3. It starts from
astro dev init(dags, include, plugins, tests and a Runtime Dockerfile that runs Airflow locally in Docker) and grows into dags grouped by business area, logic in a tested include package, asset-driven scheduling, data quality checks, alerts, CI that parses and tests every dag, and dag-only deploys. A self-hosted docker compose and Helm route is shown alongside. - GenAI RAG app (FastAPI) project structureFor developers turning a "chat with your documents" demo into an app people can rely on. A FastAPI backend where every layer has a home: ingestion workers, retrieval, prompts as versioned files, model clients with fallbacks and cost caps, guards, evals that gate CI, and tracing, so a wrong answer can be traced to the step that caused it.
Career questions
See all- What is the difference between a data analyst, a data scientist and a machine learning engineer?Analysts answer business questions with SQL, spreadsheets, dashboards and reports. Data scientists add statistics, experiments and predictive models. ML engineers build and run models inside production software. Titles vary by company, so read the work in the job advert, and pick by the kind of problem you enjoy, not the title that sounds most senior.
- Should I learn Python or R for data science?For most people aiming at industry jobs, learn Python first: it covers analysis, machine learning and production code, and most data job adverts ask for it. Choose R first if you are heading into statistics, academic research, public health or survey work, where it is strong. Either way, SQL comes too, and the concepts transfer.
- How do I move into AI engineering, data science or DevOps?Pick the field by the work you want to do every day, not by the hype. Use what you already know as a bridge: developers usually reach AI engineering or DevOps fastest, analysts reach data science fastest, and a portfolio of one or two serious projects matters more than certificates.
Stuck on something specific?
Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.
- 1:1 Mentorship
- Fresh Graduate Mentorship
- Career Guidance
Brand deals, promos and partnerships: tauseeffayyaz@gmail.com