Project Overview :

● NumPy is an essential module for carrying out data science operations efficiently.
● NumPy stands for Numerical Python.

Matplotlib: Visualization with Python

● Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python. Matplotlib makes easy things easy and hard things possible. An object-oriented plotting library. A procedural interface is provided by the companion pyplot module, which may be imported directly. Eg: import matplotlib.pyplot as plt

Matplotlib Application Interfaces (APIs)

● Matplotlib has two major application interfaces, or styles of using the library:
● An explicit "Axes" interface that uses methods on a Figure or Axes object to create other Artists, and build a visualization step by step. This has also been called an "object-oriented" interface.
● An implicit "pyplot" interface that keeps track of the last Figure and Axes created, and adds Artists to the object it thinks the user wants.

Scatter Plot :

● A Scatter Plot (x,y) has points that show the relationship between two sets of data.
 

Requirements :
 

● Python
● VS code
● Library – numpy and matplotlib

 
Code :
 

import numpy as np import matplotlib.pyplot as plt x = np.array([3,7,8,7,2,17,2,9,4,11,12,9,6]) y = np.array([97,86,87,88,111,86,103,87,94,78,77,85,76]) plt.scatter(x, y) plt.show()
 
Code Explanation :
 

● import numpy =>import numpy as np and use it in python. In command prompt or VS code terminal run the below pip command to install numpy library,
● pip3 install numpy # For Python version 3
● import matplotlib.pyplot as plt import matplotlib and use it in python. In command prompt or VS code terminal run the below pip command to install matplotlib library,
● pip3 install matplotlib
● Here pyplot() is the most important function in matplotlib library, which is used to plot 2D data.
● x = np.array([3,7,8,7,2,17,2,9,4,11,12,9,6])
● y = np.array([97,86,87,88,111,86,103,87,94,78,77,85,76])
● Plot the x and y values.
● plt.scatter(x, y)
● plt.show()
● Run the code.

 
Output :

● After running the code, graph was generated.



« Home

×