Customizing Plots
Add titles, labels, and legends.
Customizing Plots is a free Python Academy lesson on CoddyKit — lesson 3 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 Python Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
From Raw to Readable
A bare chart shows data but tells the reader little. Customization adds the context that turns a plot into a clear message: titles, axis labels, legends, ticks, and annotations.
All of these are methods on the axes object.
Titles
Give every axes a title with ax.set_title('Monthly Sales'). A figure-wide title uses fig.suptitle('Report').
The title should state what the chart shows, not just repeat the column name.
raw_label = 'sales_q1'
nice_title = raw_label.replace('_', ' ').title()
print('Title:', nice_title)Axis Labels
Label both axes with ax.set_xlabel('Month') and ax.set_ylabel('Revenue (USD)'). Always include units when they exist.
Unlabeled axes are the most common reason a chart confuses its audience.
Legends
When an axes has multiple series, a legend identifies them. Pass a label when plotting, then call ax.legend().
The legend reads the labels you attached to each plotted line.
series = [
{'label': 'Revenue', 'color': 'blue'},
{'label': 'Costs', 'color': 'red'},
]
for s in series:
print('legend entry:', s['label'], '(' + s['color'] + ')')Colors
Set a color with the color argument. You can use names like 'red', hex codes like '#1f77b4', or short codes like 'g'.
Consistent colors across charts help readers track the same series.
Axis Limits
Control the visible range with ax.set_xlim(0, 10) and ax.set_ylim(0, 100). This is useful to zoom in or to force a zero baseline so bar heights are honest.
Here we compute a padded range automatically.
values = [12, 45, 33, 27]
lo, hi = min(values), max(values)
pad = (hi - lo) * 0.1
print('y limits:', lo - pad, 'to', hi + pad)Ticks and Tick Labels
Ticks are the marks on an axis. Set their positions with ax.set_xticks([0, 1, 2]) and their text with ax.set_xticklabels(['Jan', 'Feb', 'Mar']).
Rotating long labels with rotation=45 prevents overlap.
Gridlines
Add a grid with ax.grid(True) to help readers estimate values. Keep grids light so they do not compete with the data.
You can show only horizontal gridlines with ax.grid(axis='y').
Annotations
Call out a specific point with ax.annotate('Peak', xy=(x, y)). Annotations draw attention to the part of the chart that matters most.
Finding the point to annotate is ordinary Python.
data = [10, 25, 80, 40, 15]
peak_index = data.index(max(data))
print('Annotate peak at x =', peak_index, 'value =', data[peak_index])Layout Polish
After adding labels, call fig.tight_layout() so nothing is clipped. This automatically adjusts spacing so titles and labels fit within the figure.
It is the final touch before saving or displaying.
Text Styling
Most text methods accept styling arguments: fontsize, fontweight='bold', and color. For example ax.set_title('Sales', fontsize=16, fontweight='bold') emphasizes the title.
Use emphasis sparingly so the data, not the decoration, stays the focus.
Quick Check
Pick the right method for the job.
Recap
You learned the customization toolkit:
set_title,set_xlabel,set_ylabelfor contextlegendfor naming series,colorfor consistencyset_xlim/set_ylim, ticks, andgridannotatefor emphasis andtight_layoutfor polish
Together they turn raw data into a clear story.
Frequently asked questions
Is the “Customizing Plots” lesson free?
Yes — the full text of “Customizing Plots” is free to read here on the web, and the Python 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 Python Academy course, upgrade to CoddyKit PRO.
What will I learn in “Customizing Plots”?
Add titles, labels, and legends. You practise Python 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 Python Academy?
No prior experience is required. Python Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Customizing Plots” 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 Python Academy lesson?
Yes. Every Python 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
- Figures and Axes
- Line, Bar and Scatter Plots
- Customizing Plots
- Subplots and Layouts