Your First Matplotlib Lab

PythonBeginner
Practice Now

Introduction

Hi there, welcome to LabEx! In this first lab, you'll learn the classic "Hello, World!" program in Matplotlib.

Click the Continue button below to start the lab.

This is a Guided Lab, which provides step-by-step instructions to help you learn and practice. Follow the instructions carefully to complete each step and gain hands-on experience. Historical data shows that this is a beginner level lab with a 93% completion rate. It has received a 100% positive review rate from learners.

Hello Matplotlib

Let's start by importing the Matplotlib library. Open a new terminal and type:

python3
Python interpreter terminal window

This will open a Python interpreter. Now, let's import the Matplotlib library:

import matplotlib.pyplot as plt

Now, let's create a NumPy array with 1000 values between 0 and 2π:

import numpy as np
x = np.linspace(0, 2*np.pi, 1000)

Now, let's create a plot and show it:

plt.plot(x, np.sin(x))
plt.show()
sine wave plot example

Summary

Congratulations! You have completed your first LabEx Lab.

If you want to learn more about LabEx and how to use it, you can visit our Support Center . Or you can watch the video to learn more about LabEx.

Programming is a long journey, but Next Lab is just one click away. Let's do it!