Exercises: Theming and Branding
Part A: Conceptual (6 problems)
A.1 ★☆☆ | Recall
Name five components of a visualization style guide.
Guidance
Color system, typography, chart anatomy, data encoding conventions, annotation style, layout rules, accessibility requirements, examples, do's and don'ts, implementation details.A.2 ★☆☆ | Recall
What is the chapter's threshold concept?
Guidance
"Style is a system, not a one-off." A visualization brand is a codified system (colors, fonts, templates) that makes consistency automatic rather than effortful.A.3 ★★☆ | Understand
Why should a brand color system include separate categorical, sequential, and diverging palettes?
Guidance
Different data types call for different palettes. Categorical (unordered groups) needs distinguishable colors. Sequential (ordered quantities) needs a gradient from light to dark. Diverging (values with a meaningful midpoint) needs two hues with a neutral midpoint. One palette cannot serve all three purposes.A.4 ★★☆ | Understand
What is a matplotlib style sheet, and how does it differ from setting rcParams in Python code?
Guidance
A style sheet is a `.mplstyle` file with rcParams settings. Apply with `plt.style.use("name")`. Advantages over inline rcParams: reusable across scripts, shareable as a file, easy to swap, composable with `plt.style.use(["base", "brand"])`.A.5 ★★★ | Analyze
Why is FiveThirtyEight's style recognizable after decades of data journalism?
Guidance
Consistency of choices: distinctive color palette (warm blues, reds, yellows, greens), light gray background, specific typography, consistent chart chrome. Every FiveThirtyEight chart follows the same rules, and over time readers learn to recognize them. The style became the house style of data journalism.A.6 ★★★ | Evaluate
A company adopts a new brand and wants all existing dashboards to match. What is your migration plan?
Guidance
(1) Version the brand (old = v1, new = v2). (2) Build the v2 style sheet, template, helper module. (3) Migrate high-visibility dashboards first. (4) Set a deadline for low-visibility migration. (5) Provide tooling that converts v1 to v2 where possible. (6) Document the changes in a change log. (7) Solicit feedback and iterate. Avoid breaking all dashboards simultaneously.Part B: Applied (10 problems)
B.1 ★☆☆ | Apply
Create a matplotlib style sheet with specific fonts, colors, and axes settings.
Guidance
# mybrand.mplstyle
font.family: sans-serif
font.sans-serif: Helvetica, Arial, DejaVu Sans
font.size: 11
axes.spines.top: False
axes.spines.right: False
axes.grid: True
grid.color: E0E0E0
axes.prop_cycle: cycler('color', ['1F77B4', 'FF7F0E', '2CA02C'])
figure.facecolor: white
Apply with `plt.style.use("path/to/mybrand.mplstyle")`.
B.2 ★☆☆ | Apply
Apply the style sheet and produce a simple chart. Compare to the default style.
Guidance
import matplotlib.pyplot as plt
plt.style.use("mybrand")
fig, ax = plt.subplots()
ax.plot([1, 2, 3], [4, 5, 6])
ax.set_title("Branded Chart")
plt.show()
The styled chart should have your brand colors, fonts, and grid.
B.3 ★★☆ | Apply
Create a Plotly template with brand colors, fonts, and axes.
Guidance
import plotly.graph_objects as go
import plotly.io as pio
template = go.layout.Template(layout=dict(
font=dict(family="Helvetica", size=12, color="#333"),
colorway=["#1F77B4", "#FF7F0E", "#2CA02C"],
plot_bgcolor="white",
xaxis=dict(gridcolor="#E0E0E0", zeroline=False),
yaxis=dict(gridcolor="#E0E0E0", zeroline=False),
))
pio.templates["mybrand"] = template
pio.templates.default = "plotly_white+mybrand"
B.4 ★★☆ | Apply
Write a helper function branded_axes(figsize) that returns a figure and axes with brand defaults.
Guidance
def branded_axes(figsize=(7, 4.5)):
plt.style.use("mybrand")
fig, ax = plt.subplots(figsize=figsize)
return fig, ax
B.5 ★★☆ | Apply
Write a helper function add_title(ax, title, subtitle) that adds a branded title and subtitle.
Guidance
def add_title(ax, title, subtitle=None):
ax.set_title(title, fontsize=14, fontweight="bold", loc="left", pad=20)
if subtitle:
ax.text(0, 1.02, subtitle, transform=ax.transAxes,
fontsize=11, color="#999")
B.6 ★★☆ | Apply
Write a function save_branded(fig, filename) that saves a figure with brand export defaults.
Guidance
def save_branded(fig, filename, dpi=300):
fig.savefig(filename, dpi=dpi, bbox_inches="tight", facecolor="white")
B.7 ★★★ | Apply
Build a complete brand module with colors, style sheet apply, helper functions, and Plotly template. Test by producing 3 different chart types.
Guidance
Combine B.1-B.6 plus a Plotly template setup into one `brand.py` module. Test with a line chart, a bar chart, and a scatter plot. Verify all three look consistent.B.8 ★★☆ | Apply
Take a chart built without a brand and rebuild it with your brand module. Compare before and after.
Guidance
Pick any existing chart, apply the brand, and save both versions. The branded version should have consistent fonts, colors, title style, and source attribution. The improvement should be visible even in a single chart.B.9 ★★☆ | Apply
Write a validate_brand_compliance(fig) function that checks a figure for brand compliance.
Guidance
def validate_brand_compliance(fig):
issues = []
for ax in fig.axes:
if ax.title.get_fontsize() < 14:
issues.append("Title font too small")
if ax.get_facecolor() != (1, 1, 1, 1): # white
issues.append("Axes background should be white")
# ... more checks ...
return issues
B.10 ★★★ | Create
Design and build a complete brand system for a fictional organization ("Climate Observatory" or similar). Include style sheet, template, helper module, and a 6-chart gallery demonstrating the brand.
Guidance
Follow Section 32.11 as a template. Define the colors, fonts, and rules; implement in matplotlib and Plotly; produce the gallery of line, bar, scatter, histogram, heatmap, and multi-panel charts.Part C: Synthesis (4 problems)
C.1 ★★★ | Analyze
Take an existing corporate brand guide and adapt it for data visualization. Document the adaptation process.
Guidance
Follow Section 32.9: extract colors, test colorblind safety, identify fonts, fill in chart-specific gaps, build implementation, get design approval, document. Write a short memo describing your choices and the rationale.C.2 ★★★ | Evaluate
You inherit a team with 50 dashboards, each in a different style. Propose a branding migration plan.
Guidance
(1) Audit existing dashboards to understand the range of styles. (2) Design a target brand. (3) Build the brand system. (4) Prioritize dashboards by visibility and effort. (5) Migrate high-priority ones first; provide tooling/templates. (6) Set a deadline for full migration. (7) Monitor compliance. (8) Collect feedback and iterate.C.3 ★★★ | Create
Write a style guide document for your fictional brand, including rules, examples, and do's/don'ts.
Guidance
About 5-10 pages covering color, fonts, chart anatomy, encoding conventions, annotation style, layout, accessibility, examples. Include at least 3 before/after examples showing branded vs. unbranded versions.C.4 ★★★ | Evaluate
The chapter argues "style is a system, not a one-off." Discuss in the context of your own work. Do you have a personal or team brand system?
Guidance
Reflect on your practice. Common answers: individual preferences that function as a brand (a few colors you always use, a default figsize), or a team style that emerged informally. The exercise is to make the implicit explicit — codify what you already do into a formal system.Chapter 33 integrates everything into an 8-step workflow from question to published chart.