لَآ إِلَـٰهَ إِلَّا هُوَ
LA ILAHA ILLA HU
Allah, Your Lord There Is No Deity Except Him.

# Python Data Science Matplotlib Plotting

Plotting x and y points :

The plot() function is used for drawing points (markers) in a diagram.
By default, the plot() function draws a line from point to point.
The function takes parameters for specifying the points in the diagram.
The Parameter 1 is an array containing the points on the x-axis.
The Parameter 2 is an array containing the points on the y-axis.

Example

Draw a line in a diagram from position (2, 9) to position (4, 10):

import matplotlib.pyplot as plt import numpy as np

xpoints = np.array([2, 9]) ypoints = np.array([4, 10])

plt.plot(xpoints, ypoints) plt.show()

the output will be

In the graph above:
The x-axis is the horizontal axis.
The y-axis is the vertical axis.

Plotting Without Line Example If you want to draw a plot without a line from position (1, 8) to position (3, 10):

the code will be

import matplotlib.pyplot as plt
import numpy as np

xpoints = np.array([1, 8])
ypoints = np.array([3, 10])

plt.plot(xpoints, ypoints, 'o')
plt.show()

the output will be

Multiple Points One can plot as many points as one likes, you just have to ensure that there are same number of points in both the axis.

Example If you want to draw a line in a diagram from position (2, 4) to (3, 9) then to (7, 1) and finally to position (6, 10):

the code will be

import matplotlib.pyplot as plt
import numpy as np

xpoints = np.array([2, 3, 7, 6])
ypoints = np.array([4, 9, 1, 10])

plt.plot(xpoints, ypoints)
plt.show()

the output will be

Default X - Points If the point on x axis are not defined than the point on x axis will be assigned the default values begining with 0 like 0,1,2,3,4 etc depending upon the length of y axis.
Example: if you want to draw a graph with given
y=([3, 8, 1, 10, 5, 7])
and leave out the x-points, the diagram will look like.

The x-points in the example above are [0, 1, 2, 3, 4, 5].