×

How to Install Matplotlib in Python?

How to Install Matplotlib in Python

The speed at which the enormous amount of data is generating has become a huge aid in understanding what's going on currently in the market. The people who are associated with industries now have a better idea of how they can flourish their business. The tech giants are now able to make much wiser decisions on investments because they know exactly what's in trend. Let's see what is that one thing that is making everything possible? The answer is data.

Once the data is collected and the useful features are extracted comes the most critical part which is visualization.

Matplotlib is a vast and interesting library for people who are enthusiastic about inferring results from the data.

There are scatter plots, histograms, box plots, and a lot more which makes it easy for us to comprehend.

In this article, we will discuss how to install matplotlib in Python.

  1. Checking the version of Python installed in our PCs, we have discussed this already in the previous articles but let’s talk about this again-

There are two ways to check the version of Python in Windows-

  • Using Powershell
  • Using Command Prompt

Using Powershell

  1. Click ‘Win+R’ or type ‘Run’ on the taskbar’s search pane.
How to Install Matplotlib in Python
  1. Type ‘Powershell.’
How to Install Matplotlib in Python
  1. A window will appear on your screen named ‘Windows Powershell’
How to Install Matplotlib in Python
  1. Click on ‘Enter’
  2. Type python –version and click on ‘Enter’
  3. The version would be displayed in the next line.
How to Install Matplotlib in Python

Using Command Prompt

How to Install Matplotlib in Python

Type 'Command Prompt' on the taskbar's search pane and you'll see its icon. Click on it to open the command prompt.

Also, you can directly click on its icon if it is pinned on the taskbar.

  1. Once the ‘Command Prompt’ screen is visible on your screen.
  2. Type python –version and click on ‘Enter’.
  3. The version installed in your system would be displayed in the next line.

Checking the version of Python in Linux

In Linux, we have a shell where we type our commands that are interpreted and tell the operating system about what the user wants.

The steps to check the version of Python in Linux is-

  • Start your system and switch on to the Linux operating system (you might find it with the name Ubuntu).
  • Once the desktop screen of Linux appears, click on ‘Terminal’ to open it.
  • In the terminal window, type python –version and click on ‘Enter’.

In the next line, it will display the current version of python installed in your system.

  1. The next step is to use the pip command to install NumPy in our system

Simply writing the pip command in the command prompt can help us to download & manage packages.

Packages contain all the necessary files for a module and modules are the in-built codes that can be used directly in our python projects.

Installing pip in python (Windows)

  • First of all, to check the version of python installed on our PCs we will type the python –version in the command prompt.
  • If you have Python 2.7(or greater) or Python 3.4(or greater) you need not install pip because it is present by default in these versions.
  • Download the get-pip.py installer script and save it with the extension .py
  • The next step is to open the command prompt and run the command

get-pip.py

  • Now this pip is installed successfully in your system.
  • We can check the version of the pip using the pip –version.

Installing pip in python (Linux)

Linux has a great variety of commands. Since it follows the shell scripting way of interaction, the OS understands our tasks through commands. In Linux, the commands for installing pip vary with the version of Python.

We will look at some of them here-

First, we will see how to install pip in Python3

 sudo apt update
sudo apt install python-3 pip 

We can check its version after the successful installation

pip3 –version

Using Command Prompt

Matplotlib can be installed in our system by using the given command in the Command Prompt-

pip install matplotlib

USING ANACONDA

We can install matplotlib using Anaconda by typing the following command in the Anaconda Prompt-

conda install matplotlib
How to Install Matplotlib in Python

Verifying the Installation

We can verify that matplotlib has been successfully installed in our system or not by typing the given program in the terminal-

 import matplotlib
matplotlib.__version__ 

Let us see how we can create a line chart using matplotlib-

 import numpy as np
import matplotlib.pyplot as plt
x=np.linspace(-20,9,10)
y=x**2
plt.plot(x,y,'b')
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('Representation of Square Function')
plt.show() 

INPUT-

How to Install Matplotlib in Python

OUTPUT-

How to Install Matplotlib in Python

So, in this article how the matplotlib library can help us and what are the ways of installing it.


Related Topics

Python program to count and display vowels in a string

Python program to count and display vowels in a string This python program counts the vowels in a string and displays them on the screen. We can do this in several...

2 minutes read.

How to convert integer to float in Python

Python is an Object-Oriented high-level language. Python has an English-like syntax, which is very easy to read and write codes. Python is an interpreted language which means that it uses...

5 minutes read.

Parameter Passing in Python

In Python, when we characterize capabilities with default values for specific boundaries, it is said to have its contentions set as a possibility for the client. Clients can either pass their...

3 minutes read.

Python Stack

Python Stack: The work Stack is defined as arranging a pile of objects or items on top of another. It is the same method of allocating memory in the stack...

10 minutes read.

Python Program to Find the Greatest Among Three Numbers

Python Program to find the greatest among three numbers We have many approaches to get the largest of three numbers, and here we will discuss a few of them. This python...

2 minutes read.

Python If-else statement

In real life, there are situations where we have to make decisions for a particular circumstance and based on those decisions, and we plan our next move. The same thing...

4 minutes read.

Anaconda python 3.7 download for windows 10 64-bit

Before installing Anaconda, you need to first know what Anaconda actually is. Anaconda is an IDE (Integrated development environment) platform used to code and executes python programs. Anaconda works both online...

3 minutes read.

Python frozenset()

Python frozenset() class The frozenset() class in Python returns a new frozenset object, optionally with elements taken from iterable. Syntax class frozenset([iterable]) Parameter iterable: This parameter represents an iterable object, like list, set, tuple etc. Return This class returns an unchangeable...

1 minute read.

Genetic Algorithm in python

Python : Python is an object oriented programming language which is highly interpreted and is highly interactive. Python was created by Guido van Rossum in the year 1985 – 1990 .The source...

4 minutes read.

Sort Dictionary in Python

Dictionaries In Python, a dictionary is an unordered collection or set of data types that enable of store data in an unordered key-value/pair. The key is stored alongside with value. Dictionary contains key:...

4 minutes read.

Application to Search Installed Application using Tkinter in Python

Tkinter: The standard Python technique for building Graphical User Interfaces (GUIs) is Tkinter, which is included in all popular Python distributions. The only framework included in the Python standard library is...

4 minutes read.

Application to get live USD/INR rate Using Tkinter in Python

Tkinter: The standard Python technique for building Graphical User Interfaces (GUIs) is Tkinter, which is included in all popular Python distributions. The only framework included in the Python standard library is...

4 minutes read.

Append key Value to Dictionary in Python

The Python dictionary is one of the built-in data types. Elements of dictionaries are key-value pairs. In Python, there are numerous ways to add dictionaries. Let's examine some of the...

9 minutes read.

Subprocess in Python

In this tutorial, we will understand what is a subprocess in python and will understand how to use it. Subprocess A subprocess is a very prevailing portion of the python library. It...

3 minutes read.

Python String join() method

Python String join() method The String.join() method in Python concatenates each element of an iterable (such as list, string and tuple) to the given string and returns the concatenated string. Syntax string.join(seq) Parameter Seq: This...

1 minute read.

How to Define a Function in Python?

What is a Function? In programming, a piece of code that executes a specific task or a group of related operations is known as a function. What does Python Functions Do? If you...

6 minutes read.

Add in Dictionary Python

Dictionary in python: Dictionaries are a useful data configuration for storing information in Python because they can mimic real-world data arrangements where a particular value exists for a particular key. The...

4 minutes read.

How to plot multiple linear regression in Python

This article lets us look into linear regression in Python and how we can plot multiple linear regressions in it. Linear regression One of the simplest and most widely used Machine Learning...

4 minutes read.

What is a Script in Python

Have you ever heard that Python is a scripting language? Or when people address a Python program file as a script? Besides programming, script generally means "a written story for...

3 minutes read.

End Parameter in python

print(): The python print() function prints the program’s output to the output screen. The output can be an integer value, string value or other value. Syntax: print(“hi”) Output: hi will be displayed on the output...

3 minutes read.