Loading

Quipoin Menu

Learn • Practice • Grow

python-for-ai / Customizing Plots
tutorial

Customizing Plots

Making your plots clear and professional requires customization: adding labels, titles, legends, adjusting colors, and saving figures. This chapter covers the most common customizations.

Adding Labels, Title, and Legend

import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y1 = [2,4,6,8,10]
y2 = [1,3,5,7,9]

plt.plot(x, y1, label='Line A', color='blue', linestyle='-')
plt.plot(x, y2, label='Line B', color='red', linestyle='--')

plt.title('Comparison of Two Lines')
plt.xlabel('X axis')
plt.ylabel('Y axis')
plt.legend()
plt.grid(True, linestyle=':', alpha=0.7)
plt.show()

Adjusting Figure Size and DPI

plt.figure(figsize=(10,6), dpi=100)
plt.plot(x, y1)
plt.show()

Saving Figures

plt.savefig('plot.png', dpi=300, bbox_inches='tight')

Subplots (Multiple Plots in One Figure)

fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10,4))
ax1.plot(x, y1)
ax1.set_title('Line A')
ax2.bar(x, y2)
ax2.set_title('Bar Chart')
plt.tight_layout()
plt.show()

Why Customization Matters in AI

Clear visualizations help you debug models (e.g., loss curves) and present results to non‑technical audiences. Customized plots are essential for reports and publications.


Two Minute Drill
  • plt.xlabel(), plt.ylabel(), plt.title(), plt.legend().
  • Use plt.figure(figsize=(w,h)) to set size.
  • Save with plt.savefig().
  • Subplots: fig, axes = plt.subplots(nrows, ncols).

Need more clarification?

Drop us an email at career@quipoinfotech.com