Choosing Charts and Keeping Them Honest

A chart can tell the truth badly, or mislead without meaning to. Using a city's recycling numbers, choose the chart that fits the question, write titles that state the finding, keep axes honest, make charts that everyone can read without relying on color, and put several charts on one saved page.

Updated

Choosing the Chart

  1. Choosing the Chart for the Question (Journeyman): The question you're answering picks the chart, a line for change over time, bars to compare groups, a scatter plot for two things that may move together, a histogram for how values are spread, and sorted bars of shares for the parts of a whole, because a pie's slices are hard to compare by eye.
  2. Titles, Labels and Units That Explain (Journeyman): A chart explains itself when its title states the finding, each axis label names what it measures and its unit, its tick labels are readable, an arrow from ax.annotate points at the one value that matters, and a legend appears only when there's more than one line to tell apart.

Honest Charts

  1. Honest Axes: Where the Scale Starts (Journeyman): A bar's length is its value, so a bar chart's y-axis starts at zero with ax.set_ylim(bottom=0), because an axis that starts higher makes a small difference look several times bigger; a line chart may zoom in if its label says so, and side-by-side charts share one scale with sharey=True.
  2. Charts Everyone Can Read (Journeyman): About one man in twelve can't tell red from green, so a chart never lets color carry the meaning alone, adding markers, line styles and labels on the lines, using a colorblind-friendly style such as tableau-colorblind10, keeping text big enough to read, and giving a chart in a report a sentence of alt text.

Several Charts on a Page

  1. Several Charts on One Page: subplots and savefig (Journeyman): plt.subplots(2, 2, figsize=(10, 8), layout="constrained") makes one page with a grid of four Axes, each chart is drawn on its own Axes such as axs[0, 0], fig.suptitle gives the page a title, and fig.savefig saves it with dpi and bbox_inches="tight", as a PNG for a report or an SVG that stays sharp at any size.

Exercise: Fix the Misleading Charts

  1. Exercise: Fix the Misleading Charts (Journeyman): Fix four charts of a city's recycling numbers that run but mislead, a bar chart whose axis starts at 40, a line with no title or labels, two lines told apart only by red and green, and two charts side by side on different scales, then put four charts on one page saved as a PNG, and let pytest read each chart's Axes.

Up Next: A Report Someone Can Use

  1. Up Next: A Report Someone Can Use (Journeyman): Look back at what Module 4 taught (line, bar, scatter and histogram charts, choosing the chart for the question, titles and labels that explain, honest axes, charts everyone can read, several charts on one saved page), try a one-page chart summary of your own, and see what Module 5 adds, a report someone else can follow and rebuild.