How to Install Matplotlib on Linux?
Last Updated :
23 Jul, 2025
Matplotlib is a low-level library of Python which is used for data visualization. It is easy to use and emulates MATLAB like graphs and visualization. This library is built on the top of NumPy arrays and consist of several plots like line chart, bar chart, histogram, etc. It provides a lot of flexibility but at the cost of writing more code.
Environment Setup:
Matplotlib is an overall package for creating static, animated, and interactive visualizations in Python. It literally opens up a whole new world of possibilities for you! Especially when it is used with Numpy or Pandas library, one can do unimaginable things. The plots give may give a new insight altogether. Now, the question arises i.e. How to make it running on your computer? But a more primary question would be, what are its pre-requisites or as we call it, dependencies for the software to run on your computer?
Dependencies:
- Python (>= 3.6)
- FreeType (>= 2.3)
- libpng (>= 1.2)
- NumPy (>= 1.11)
- setuptools
- cycler (>= 0.10.0)
- dateutil (>= 2.1)
- kiwisolver (>= 1.0.0)
- pyparsing
Installation on Linux:
We will use the pip command to install this module. If you do not have pip installed then refer to the article, Download and install pip Latest Version.
To install Matplotlib type the below command in the terminal:
pip install matplotlib
You will get the following message once the installation is complete:

Let's see some examples of using matplotlib:
Example 1: Creating Line plots
Python3
# importing matplotlib module
from matplotlib import pyplot as plt
# x-axis values
x = [5, 2, 9, 4, 7]
# Y-axis values
y = [10, 5, 8, 4, 2]
# Function to plot
plt.plot(x,y)
# function to show the plot
plt.show()
Output:

Example 2: Creating Bar plots
Python3
# importing matplotlib module
from matplotlib import pyplot as plt
# x-axis values
x = [5, 2, 9, 4, 7]
# Y-axis values
y = [10, 5, 8, 4, 2]
# Function to plot the bar
plt.bar(x,y)
# function to show the plot
plt.show()
Output:

Example 3: Creating Scatter plots
Python3
# importing matplotlib module
from matplotlib import pyplot as plt
# x-axis values
x = [5, 2, 9, 4, 7]
# Y-axis values
y = [10, 5, 8, 4, 2]
# Function to plot scatter
plt.scatter(x, y)
# function to show the plot
plt.show()
Output:

Similar Reads
How to Install Matplotlib on MacOS? In this article, we will learn how to install Matplotlib in Python on MacOS. Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python. Installation:Method 1: Using pip to install Matplotlib Package Follow the below steps to install the Matplotlib
2 min read
How to Install Numpy on Linux? Python NumPy is a general-purpose array processing package that provides tools for handling n-dimensional arrays. It provides various computing tools such as comprehensive mathematical functions, linear algebra routines. NumPy provides both the flexibility of Python and the speed of well-optimized c
2 min read
How to Install NuPIC on Linux? NuPIC (short for "Numenta Platform for Intelligent Computing") is an open-source platform for machine learning and artificial intelligence. It was developed by Numenta, a company founded by Jeff Hawkins, the creator of the PalmPilot and the co-founder of Handspring. NuPIC is based on the theory of t
4 min read
How to Install Matplotlib on python? Matplotlib is a Python library used for creating 2D plots and visualizations. It is built on top of NumPy and works well with the broader SciPy stack. This guide explains how to install Matplotlib on Windows using both Conda and PIP.Installation Using CondaIf you're using Anaconda, you can install M
2 min read
How to Install Matplotlib on Anaconda? Matplotlib is a Python library for data visualization that allows users to create static, interactive, and animated plots. If you're using Anaconda, a leading platform for Python data science, installing Matplotlib is straightforward. This guide provides you with detailed instructions to install Mat
2 min read
How to Install Pillow on Linux? In this article, we will look into the various methods of installing the PIL package on a Linux machine. Python Imaging Library (expansion of PIL) is the de facto image processing package for Python language. It incorporates lightweight image processing tools that aid in editing, creating, and savin
2 min read