How to import matplotlib in Python? Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report Matplotlib is a Python library used to create different types of charts and graphs. It helps to turn data into visual formats like line charts, bar graphs and histograms. This makes it easier to understand and present your data. In this guide you’ll learn how to install and import Matplotlib in Python step by step.Step 1: Install Matplotlib Before using Matplotlib you need to make sure it is installed on your computer. You can install it using pip (Python's package installer).Open your command prompt or terminal.Run the following command to install Matplotlib:pip install matplotlibInstalling MatplotlibStep 2: Import Matplotlib - Add the import module statementAfter installation you can import Matplotlib in your Python code. The common way is to import its pyplot module like in below image:installing/importing MatplotlibLet's create a simple line chart after successfully importing matplotlib to verify the installation: Python import matplotlib.pyplot as plt x = [1, 2, 3, 4, 5] y = [2, 4, 6, 8, 10] plt.plot(x, y) plt.show() Output:SImple line chart on Matplotlib For more details you can refer to: How to Install Matplotlib on python? Matplotlib Tutorial Comment More info H hardiksharmmaaaa Follow Improve Article Tags : Data Visualization AI-ML-DS Python-matplotlib AI-ML-DS With Python Explore Python - Data visualization tutorial 5 min read What is Data Visualization and Why is It Important? 4 min read Data Visualization using Matplotlib in Python 11 min read Data Visualization with Seaborn - Python 9 min read Data Visualization with Pandas 6 min read Plotly for Data Visualization in Python 12 min read Data Visualization using Plotnine and ggplot2 in Python 6 min read Introduction to Altair in Python 4 min read Python - Data visualization using Bokeh 4 min read Pygal Introduction 5 min read Like