Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Matplotlib Basics: P | Master Data Science with Python lesso | BraveProgrammer
  1. Courses
  2. /
  3. Master Data Science with Python

Lesson 31 of 60

·python

Matplotlib Basics: Plotting with Python

15 minutes

Course progress52%

Matplotlib Basics

Matplotlib is the foundational plotting library in Python. It works well for static images and integrates tightly with Pandas.

Importing the library

import matplotlib.pyplot as plt

Simple line plot

x = [1, 2, 3, , ]
y = [, , , , ]
plt.plot(x, y, marker=, linestyle=)
plt.title()
plt.xlabel()
plt.ylabel()
plt.show()
4
5
2
3
5
7
11
'o'
'-'
'Simple Line Plot'
'X axis'
'Y axis'

Saving a figure

plt.savefig('images/line_plot.png', dpi=300, bbox_inches='tight')

The Figure and Axes objects

fig, ax = plt.subplots(figsize=(6,4))
ax.plot(x, y, color='purple')
ax.set_title('Figure & Axes Example')
plt.show()

Info

Use the %matplotlib inline magic in Jupyter to embed plots directly in the notebook.
Make it stickPractice what you've learned1 quiz · 4 practical tests · Optional activities from Master Data Science with PythonBrowse activities
Previous lessonPandas Project: Titanic Data AnalysisContinue to lesson 32Line, Scatter, and Bar ChartsBack to Master Data Science with Python curriculum