Matplotlib File
Matplotlib File
x=["python","c","c++","java"]
y=[85,70,60,82]
z=[20,30,40,50]
width=0.2
p=np.arange(len(x))
p1=[j+width for j in p]
plt.xlabel("language",fontsize=15)
plt.ylabel("No.",fontsize=15)
plt.title("wscube",fontsize=15)
plt.bar(p,y,width,color="r",label="popularity")
plt.bar(p1,z,width,color="y",label="popularity1")
plt.xticks(p+width/2,x,rotation=15) # plt.xticks(position,Name,)
plt.legend()
plt.show()
Scatter Plot
import matplotlib.pyplot as plt
fig=plt.figure(figsize=(8,6))
ax=fig.add_subplot(111)
day=[1,2,3,4,5,6,7]
no=[2,3,1,4,5,3,6]
ax.set(title="scatter plot",xlabel="Day",ylabel="No")
plt.scatter(day,no,color="r")
plt.show()
plt.show()
# show plot
plt.show()
Hist Plot
from matplotlib import pyplot as plt
import numpy as np
# Creating dataset
a = np.array([22, 87, 5, 43, 56,
73, 55, 54, 11,
20, 51, 5, 79, 31,
27])
# Creating histogram
fig, ax = plt.subplots(figsize =(10, 7))
ax.hist(a, bins = [0, 25, 50, 75, 100])
# Show plot
plt.show()