0Pricing
Pandas & NumPy Academy · Lesson

Labels, Titles, and Saving Figures

Add axis labels, a title, a legend, and tick formatting, then save publication-quality figures with savefig().

From Plot to Publication

A chart is only effective if its axes are labelled, its title explains the takeaway, and it is saved at high enough resolution for its intended medium. This lesson covers the finishing touches that transform a quick exploratory plot into a polished figure suitable for a report, dashboard, or academic publication: axis labels, tick formatting, titles, legends, annotations, and file export.

Axis Labels with set_xlabel and set_ylabel

Set descriptive axis labels with ax.set_xlabel() and ax.set_ylabel(). Always include units in the label (e.g., 'Revenue (USD)' rather than just 'Revenue'). Use fontsize to make labels larger for presentations, and labelpad to add space between the axis and the label text when ticks are large.

import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots(figsize=(7, 4))
x = np.arange(1, 13)
y = np.random.randint(100, 500, 12)
ax.plot(x, y, 'o-', color='steelblue')

ax.set_xlabel('Month', fontsize=12, labelpad=8)
ax.set_ylabel('Revenue (USD thousands)', fontsize=12, labelpad=8)
# plt.show()
plt.close()

All lessons in this course

  1. Figure and Axes Architecture
  2. Line and Scatter Plots
  3. Bar Charts and Histograms
  4. Labels, Titles, and Saving Figures
← Back to Pandas & NumPy Academy