Visualization: Turning Numbers Into Decisions

A well-chosen chart communicates what a table cannot. This module covers the visualizations that matter for data exploration and how to choose among them.

The Right Chart Changes Decisions

A table of numbers and the right chart of the same numbers can produce completely different decisions. The human visual system is extraordinarily good at detecting patterns, outliers, and trends in visual form - and extraordinarily bad at doing the same with raw numbers.

Visualization is not decoration. It is the primary tool for communicating what data shows and for discovering things in data that summary statistics miss.

Choosing the Right Chart Type

Histogram: Showing Distribution

A histogram shows how values are distributed across a range. Use it when you want to answer: "What does the spread of this variable look like? Where are most values? Are there outliers?"

python
import matplotlib.pyplot as plt df["Age"].hist(bins=20) plt.title("Distribution of Passenger Ages") plt.xlabel("Age") plt.ylabel("Count") plt.show()

What to look for: Is the distribution symmetric or skewed? Are there multiple peaks? Are there extreme outliers?

Bar Chart: Comparing Categories

A bar chart compares a numeric value across categories. Use it when you want to answer: "How does this metric differ across groups?"

python
survival_by_class = df.groupby("Pclass")["Survived"].mean() survival_by_class.plot(kind="bar") plt.title("Survival Rate by Passenger Class") plt.xlabel("Class") plt.ylabel("Survival Rate") plt.xticks(rotation=0) plt.show()

Scatter Plot: Showing Relationships Between Two Variables

A scatter plot shows the relationship between two numeric variables. Use it when you want to answer: "Is there a relationship between X and Y?"

python
plt.scatter(df["Age"], df["Fare"], alpha=0.3) plt.xlabel("Age") plt.ylabel("Fare Paid") plt.title("Age vs. Fare") plt.show()

alpha=0.3 makes points semi-transparent so you can see density where many points overlap.

Line Chart: Showing Trends Over Time

A line chart shows how a value changes over a continuous dimension - usually time. Use it when you want to answer: "Is this metric increasing, decreasing, or staying flat?"

python
monthly_sales.plot(kind="line") plt.title("Monthly Sales Trend") plt.xlabel("Month") plt.ylabel("Sales ($)") plt.show()

Heatmap: Showing Correlation

A correlation heatmap shows how pairs of variables are related to each other. Values close to 1 mean strongly positively correlated; close to -1 means strongly negatively correlated; close to 0 means little relationship.

python
import seaborn as sns correlation_matrix = df[["Age", "Fare", "Survived", "Pclass"]].corr() sns.heatmap(correlation_matrix, annot=True, cmap="coolwarm", center=0) plt.title("Feature Correlation Matrix") plt.show()

The One-Chart Rule

Each chart should answer exactly one question. If you are trying to show multiple things in one chart, you usually end up showing nothing clearly. State the question the chart answers in the chart's title.

Bad title: "Sales Data Analysis" Good title: "Q3 Sales Declined 18% Among Enterprise Customers"

The good title is already an insight. The reader knows what to look for before they even look.

What Makes a Visualization Misleading

Truncated Y-axis: Starting the Y-axis at a value other than zero can make small differences look dramatic. Watch for this in charts from vendors showing their product's improvement.

Cherry-picked time ranges: Choosing a start date that makes a trend look better (or worse) than the full picture.

Area charts with overlapping categories: Makes relative sizes hard to compare accurately.

Too much information: More than 5-7 categories in one chart becomes hard to read. Consider faceting or summarization.

A Complete Visualization Workflow

python
import pandas as pd import matplotlib.pyplot as plt import seaborn as sns df = pd.read_csv("titanic.csv") # Set up a figure with multiple charts fig, axes = plt.subplots(2, 2, figsize=(12, 10)) # 1. Survival rate by class df.groupby("Pclass")["Survived"].mean().plot(kind="bar", ax=axes[0,0]) axes[0,0].set_title("Survival Rate by Class") axes[0,0].set_ylabel("Survival Rate") # 2. Age distribution df["Age"].hist(bins=20, ax=axes[0,1]) axes[0,1].set_title("Age Distribution") axes[0,1].set_xlabel("Age") # 3. Fare vs survival survivors = df[df["Survived"] == 1] non_survivors = df[df["Survived"] == 0] axes[1,0].scatter(non_survivors["Age"], non_survivors["Fare"], alpha=0.3, label="Did not survive", color="red") axes[1,0].scatter(survivors["Age"], survivors["Fare"], alpha=0.3, label="Survived", color="blue") axes[1,0].set_xlabel("Age"); axes[1,0].set_ylabel("Fare") axes[1,0].set_title("Age vs Fare by Survival") axes[1,0].legend() # 4. Correlation heatmap corr = df[["Survived", "Pclass", "Age", "Fare"]].corr() sns.heatmap(corr, annot=True, ax=axes[1,1], cmap="coolwarm", center=0) axes[1,1].set_title("Feature Correlations") plt.tight_layout() plt.savefig("titanic_exploration.png", dpi=150) plt.show()

This produces a four-panel figure that captures the main patterns in the dataset. Save it, annotate the key findings in a document, and you have the deliverable for this phase's gate.

Phase 3 Gate

Before moving to Phase 4, you should be able to:

  • Load any CSV file in Python and describe its shape, types, and missing values
  • Answer analytical questions about a dataset using groupby, filtering, and sorting
  • Produce at least three different chart types that each answer a specific question
  • Write a short narrative connecting the visualizations to a real-world decision

If you have done the exercises in Modules 11-15, you are ready to build.

Where to Go Next

Phase 4 is where understanding becomes building. Module 16 walks through building a real AI application using an LLM API - no model training required.

Common Mistakes

Using pie charts for more than three categories. Human perception cannot reliably compare arc lengths or sector areas for more than about three slices. A pie chart with seven categories forces the viewer to read the legend and mentally reconstruct proportions rather than perceive them directly. Bar charts or dot plots handle multi-category comparisons far more accurately.

Plotting averages without showing variance. A single mean hides whether the underlying data is tightly clustered or wildly spread. Two groups can have the same mean but completely different distributions - one tightly concentrated and one bimodal. Always accompany means with error bars, box plots, or violin plots so the reader can assess uncertainty.

Choosing chart type before knowing the question being answered. A chart answers exactly one question clearly. Deciding on a chart type first and then figuring out what it shows leads to visualizations that are technically correct but communicatively useless. Start with the question ("are these two groups different?" or "how has this trended over time?") and let that determine the chart type.

What to Practice Next

  • Take a dataset you have access to, identify one specific question it can answer, and create a chart that answers only that question as clearly as possible.
  • Create a second chart of the same data that is technically accurate but deliberately misleading (truncated axis, cherry-picked time range, omitted variance); compare the two and reflect on what makes a visualization trustworthy.
  • Replace one pie chart you encounter this week with a bar chart and assess whether the new version communicates more clearly.

Module 16 of 25 · Curious to AI-Fluent

Related Posts

More posts

AI Agents: What They Are, What They Can Do, and How They Go Wrong

An agent is an AI that takes actions, not just answers questions. That changes what safe use looks like. Learn in plain English what agents are, how they connect to your tools, why they can be tricked by what they read, and the one question to ask before letting one act for you.

#ai-literacy#agents#prompt-injection#mcp#llm