JOVANA
Explore Library Glossary Getting Started Three Levels Fields How it works Mission
Join the mission
All guides

Choosing the right chart

Bar, line, scatter, histogram, box — each answers a different question. A simple map from 'what do I want to show?' to the right picture.

Start from the question, not the chart

When people open a spreadsheet, they often reach straight for a chart that looks impressive — a colorful pie, a 3-D bar tower. That is backwards. A chart is not decoration; it is the answer to a question. If you do not know the question, no chart can be right. So the first skill in data visualization is not drawing at all — it is asking, “What exactly do I want this picture to show?”

Almost every everyday data question is one of five kinds. Once you can name which kind you are asking, the right chart practically chooses itself. Here they are, in plain words, each with the question it answers.

  1. Comparison — “How does this number differ across categories?” (sales by region, votes by party).
  2. Distribution — “How is one number spread out?” (the ages of our users, how long requests take).
  3. Relationship — “Do two numbers move together?” (study hours vs. exam score).
  4. Trend over time — “How does this number change as time passes?” (daily sign-ups this year).
  5. Composition — “What are the parts of a whole, and how big is each?” (share of revenue by product).

This guide walks the first four — comparison, distribution, relationship, and trend — because they cover the vast majority of real work, and then it shows the encoding and layout ideas that make any of them clearer. (Composition, the share-of-a-whole question, is the one most often drawn badly; we will meet the honest way to handle it in the next guide.) Treat all of this as part of exploratory data analysis: you usually try a few of these before you find the one that tells the story.

Comparison: bar charts done right

Comparison is the most common question of all: one number, measured for several categories, and you want to see who is bigger. The natural tool is the bar chart. Each category gets a bar, and the bar’s length stands for the number. Concrete example: a coffee chain sold 1,200 cups in Taipei, 800 in Taichung, 600 in Kaohsiung, and 300 in Tainan last week. Draw four bars, sort them tallest to shortest, and the ranking is obvious in half a second.

Two habits separate a good bar chart from a misleading one. First, sort the bars by value, not alphabetically — the whole point of the chart is the order, so make the order visible. Second, and non-negotiable: the value axis must start at zero. We judge a bar by its length, so if the axis starts at, say, 500 instead of 0, a bar of 600 can look twice as tall as a bar of 550 even though the real difference is tiny. Cutting the axis this way is the classic truncated-axis trick, and on a bar chart it is simply wrong.

A few more practical tips. If the category names are long (product titles, country names), use horizontal bars so the labels are easy to read. If you are comparing the same categories in two situations — this year vs. last year — put the bars side by side (grouped) or stack them, but never use more than a handful of series or the chart turns to mush. And resist the pie chart: a pie asks your eye to compare angles and wedge areas, which humans judge far worse than the simple lengths of bars. When in doubt, a bar chart beats a pie almost every time.

import pandas as pd
# one bar per city, sorted, drawn horizontally for readable labels
sales.groupby("city")["cups"].sum().sort_values().plot.barh()
A whole comparison chart in one line of pandas: group by city, sum the cups, sort, and draw horizontal bars.
The big picture for the whole guide: each question type points to its chart. We will unpack each branch below.

A decision map. From a starting question, branches lead to chart types: comparison → bar chart; distribution → histogram or boxplot; relationship → scatter plot; trend over time → line chart; composition → a bar of parts (pie only for two or three slices).

Distribution: histograms and boxplots

A comparison chart shows one number per category. But often you have many values of a single number — the ages of ten thousand customers, the response time of a server measured a million times — and you want to see how those values are spread out. That spread is called the distribution, and the workhorse for seeing it is the histogram.

A histogram chops the range of values into equal-width buckets called bins, and draws a bar for each bin whose height is how many values fell into it. Example: take customer ages, make bins 0–9, 10–19, 20–29, and so on, count how many people land in each, and you instantly see the shape — maybe a hump around the 30s and a long tail of older customers. That shape answers questions a single average never could: Is it symmetric? Is it skewed (a long tail trailing off to one side)? Is it bimodal (two humps, often a sign that two different groups have been mixed together)?

The same data, three shapes a histogram can reveal: a symmetric bell, a right-skewed tail, and a bimodal pair of humps. A single average could not tell these apart.

Three small histograms side by side: a symmetric bell-shaped curve; a right-skewed curve with most mass on the left and a long tail to the right; and a bimodal curve with two separate humps.

The one knob that really matters is the number of bins. Too few and you blur real structure into one fat block; too many and random noise looks like a row of spikes. A rough starting point is to use about the square root of the number of observations, then adjust by eye until the shape looks honest.

\text{number of bins } k \approx \sqrt{n}, \qquad \text{bin width} = \frac{x_{\max}-x_{\min}}{k}

A starting rule of thumb for histogram bins: about √n bins, each covering an equal slice of the range. Always tweak until the picture is neither blocky nor jagged.

ages.plot.hist(bins=30)  # then change 30 up or down until the shape is honest
Drawing a histogram is one line; the craft is in choosing the bins. Try a few values of bins and keep the one that shows the real shape.

When you want to compare the distribution across several groups at once, a pile of histograms gets crowded. That is where the boxplot (box-and-whisker plot) shines. It squeezes a distribution into five numbers: the median (the middle value), the first and third quartiles Q1 and Q3 (the 25th and 75th percentiles, which form the box), and whiskers reaching out toward the rest of the data. The width of the box is the interquartile range (IQR), the spread of the middle half, and points beyond the whiskers get flagged as possible outliers.

\text{IQR}=Q_3-Q_1, \qquad \text{whiskers reach to } [\,Q_1-1.5\,\text{IQR},\ \ Q_3+1.5\,\text{IQR}\,]

How a boxplot draws its whiskers and decides which points to mark as outliers — the common 1.5 × IQR convention.

Relationship: scatter plots

The next question links two numbers: do they move together? Does an extra hour of study go with a higher exam score? Does more ad spend go with more sales? The chart for this is the scatter plot: one dot per observation, placed at its (x, y) position. Each student becomes a dot at (hours studied, score); ten thousand students make a cloud of dots, and the shape of that cloud is the answer.

When you read a scatter plot, look for four things: direction (does y rise or fall as x rises?), strength (is the cloud tight around a trend, or a vague blob?), form (a straight line, a curve, a plateau?), and anything odd (outliers far from the crowd, or separate clusters that hint at two different populations mixed together).

A single number, the correlation coefficient r, summarizes the strength and direction of a straight-line relationship. It runs from −1 to +1: near +1 the dots hug an upward line, near −1 a downward line, and near 0 there is no straight-line trend at all.

-1 \le r \le +1

The correlation coefficient r lives between −1 and +1: −1 a perfect downward line, 0 no linear trend, +1 a perfect upward line.

A scatter plot with a fitted line through it. The dots show the raw relationship; the line is a summary. Read the dots first — the line can hide what the cloud is really doing.

A scatter plot of points trending upward from lower-left to upper-right, with a straight best-fit line drawn through the middle of the cloud, indicating a positive relationship.

Trend over time: line charts

When the x-axis is time, you have a special and very common case: a trend. Daily active users across a year, a city’s monthly rainfall, a stock’s price by the minute. The right chart is the line chart: plot each time point, then connect the dots in time order. That connecting line is the whole point — it makes the rises, falls, seasonal waves, and sudden jumps leap out at the eye.

A line chart carries one strong, silent message: the connection between points is real and continuous. That is why you may only use it when the x-axis is ordered and continuous, like dates or temperatures. Never draw a line across unordered categories — connecting “Apples → Bananas → Cherries” with a line implies a smooth trend from one fruit to the next that does not exist. For separate categories, go back to bars.

Two more notes. Unlike bar charts, line charts encode position, not length, so they may start the y-axis above zero to zoom in on small but meaningful wiggles — just label the axis clearly. And when a quantity grows by percentages — a user base doubling every year — a log scale on the y-axis turns exponential growth into a straight line, which makes the growth rate readable and comparable across periods. (We will treat the honest use of scales and axes in the next guide.)

Visual encoding: position, length, color

Underneath every chart is one idea: visual encoding — turning a number into something you can see, such as a position, a length, an angle, an area, or a color. The reason a scatter plot and a bar chart work so well, and a pie chart works so poorly, is that human eyes are not equally good at reading all of these channels.

Decades of perception research give a rough ranking of how accurately people read each channel. Use it to decide which channel your most important number deserves.

  1. Position along a common scale — the most accurate. This is the scatter plot and the dot plot.
  2. Length — next best. This is the bar chart.
  3. Angle and slope — shakier. Pie wedges and line slopes live here.
  4. Area — worse still. Bubble sizes ask the eye to compare areas, which it does poorly.
  5. Color hue and shade — least accurate for a quantity. We can tell dark from light, but not “37% darker.”

The practical rule follows directly: encode your most important number with the most accurate channel the question allows — position or length — and save color for labels and emphasis, not for the main quantity. That single rule explains most of this guide’s advice in one stroke.

Color still deserves its own care, because it does three different jobs and needs a different color scale for each: a categorical palette of distinct hues to name groups (red = North, blue = South); a sequential scale from light to dark for an ordered quantity (low to high); and a diverging scale with two colors meeting at a neutral middle for data with a meaningful center (loss in one color, gain in another around zero). And whichever you pick, remember that roughly one man in twelve has some color blindness — never rely on red-versus-green alone; add labels, shapes, or direct text as a backup.

Small multiples for many groups

Sooner or later you need to show the same chart for many groups: the sales trend not for one region but for all twelve, or the age distribution for each of eight products. The tempting move is to pile every line onto one chart. With three lines that is fine; with twelve it becomes a tangle nicknamed the spaghetti chart, where no single line can be followed.

The clean solution is small multiples: a grid of small charts, one per group, all drawn the same way and — this is the crucial part — sharing the same axes and the same scale. Twelve tiny line charts, the same x-range and y-range, laid out in a 3 × 4 grid. Because every panel is identical except for its data, your eye can scan the grid and instantly spot which region is climbing, which is flat, which has a strange spike. You trade the false promise of “everything in one chart” for the real power of fast, fair comparison.

A chart-choosing cheat sheet

Put it together and the whole decision collapses to one move: name the question, then read off the chart. Here is the map, in five lines.

  1. Comparing a number across categories? → bar chart (sorted, axis from zero; horizontal if labels are long).
  2. Showing how one number is spread? → a histogram for one group; boxplots to compare many groups.
  3. Asking whether two numbers move together? → scatter plot (glance at r, but trust the cloud).
  4. Tracking a number over time? → line chart (time on x, connect the points in order).
  5. Showing parts of a whole? → usually a bar chart of the parts is clearer than a pie; reach for a pie only for two or three slices.

Two cautions to carry out the door. First, the fanciest chart is rarely the best one; a plain, well-labeled bar or line beats a dramatic 3-D rotating donut every time, because the job is understanding, not decoration. Second, choosing the right chart type is only half of honesty — the very same scatter or line can still mislead through a truncated axis, a sneaky dual axis, or a poor color choice. Picking the right picture is this guide; keeping that picture truthful is the next one.

Finally, when many of these charts are gathered for an audience to watch over time, they graduate into a dashboard. A dashboard is not a new kind of chart — it is a collection of them — so every tile still obeys the same rules: one clear question per chart, the most accurate encoding the question allows, axes that tell the truth. Master the single chart, and the dashboard takes care of itself.