Labels, Titles, and Legends
Making a chart actually readable.
Labels, Titles, and Legends is a free Data Science Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Data Science Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
A Chart Must Explain Itself
An unlabeled plot is a riddle. Good labels let a reader understand it in seconds without asking you a single question. 🏷️
Give It a Title
Add a clear headline with plt.title that states the chart message, like Monthly Sales by Region.
plt.title("Monthly Sales by Region")Name the X Axis
Label the horizontal axis with plt.xlabel so readers know what each tick along the bottom represents.
plt.xlabel("Month")Name the Y Axis
Use plt.ylabel to say what the height measures, and include the unit, like Sales in dollars.
plt.ylabel("Sales ($)")Add a Legend
When several lines share a chart, a legend maps each color to its meaning so nobody has to guess.
plt.legend()Legends Need Labels
The legend only works if each series has a label. Pass label= in every plot call, then call legend once.
plt.plot(x, y, label="North")Rotate Crowded Ticks
Long category names overlap and become unreadable. Rotate them upright with xticks and a rotation angle.
plt.xticks(rotation=45)Place the Legend
If the legend covers your data, move it. Pass loc like "upper left" to send it to a clearer corner.
plt.legend(loc="upper left")Tidy the Layout
Labels sometimes spill off the edge. Call plt.tight_layout to nudge everything into the figure neatly.
plt.tight_layout()Order of Calls Matters
Add titles and labels after you draw and before you show. matplotlib applies them to the current active axes.
Save the Finished Chart
Share your work by writing it to a file with savefig, choosing a clear name and a sharp resolution.
plt.savefig("sales.png", dpi=150)Quick Check
Two lines on one chart and nobody knows which is which. What did you forget?
Recap: Polish That Plots Earn
You now add a title, axis labels, and a legend, rotate ticks, and save the result. Your charts finally explain themselves! ✨
Frequently asked questions
Is the “Labels, Titles, and Legends” lesson free?
Yes — the full text of “Labels, Titles, and Legends” is free to read here on the web, and the Data Science Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Data Science Academy course, upgrade to CoddyKit PRO.
What will I learn in “Labels, Titles, and Legends”?
Making a chart actually readable. You practise Data Science Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Data Science Academy?
No prior experience is required. Data Science Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Labels, Titles, and Legends” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Data Science Academy lesson?
Yes. Every Data Science Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Sort by One or Many Columns
- Your First groupby Summary
- Line and Bar Charts in matplotlib
- Labels, Titles, and Legends