1. Question
import matplotlib.pyplot as plt # Import Required Package
Days = [1,2,3,4,5,6,7,8]
Speed = [60,62,61,58,56,57,46,63]
plt.plot(Days, Speed, color = 'blue') # For Create a Line Plot
plt.xlabel('Days')
plt.ylabel('Car Speed')
plt.title('Car Speed Measurement')
plt.show()
2. Question
Days = [1,2,3,4,5,6,7,8]
Speed = [60,62,61,58,56,57,46,63]
plt.plot(Days, Speed, color = 'blue', marker = 'o', ms = 20, mec = 'red', mfc = 'green', linestyle = 'dotted', linewidth = 3.5)
plt.xlabel('Days') # ms for marker size, mfc for marker face color, mec for border color
plt.ylabel('Car Speed')
plt.title('Car Speed Measurement')
plt.show()
3. Question
days = [1,2,3,4,5,6,7,8]
max_speed = [80,91,92,88,77,79,76,75]
min_speed = [42,43,40,42,33,36,34,35]
avg_speed = [46,58,57,56,40,42,41,36]
plt.figure(figsize=(8,6))
plt.subplot(2,1,1)
plt.plot(Days, max_speed, color = 'red', marker = '*', ms = 10, mec = 'red', mfc = 'orange', label = 'Maximum Speed')
plt.xlabel('Days')
plt.ylabel('Maximum Speed')
plt.title('Car Speed Measurement')
plt.legend()
plt.grid()
plt.show()
plt.figure(figsize=(8,6))
plt.subplot(2,1,2)
plt.plot(Days, min_speed, color = 'green', marker = 'o', ms = 10, mec = 'black', mfc = 'blue', label = 'Minimum Speed')
plt.xlabel('Days')
plt.ylabel('Minimum Speed')
plt.title('Car Speed Measurement')
plt.legend()
plt.grid()
plt.show()
plt.figure(figsize=(8,6))
plt.subplot(2,1,1)
plt.plot(Days, avg_speed, color = 'yellow', marker = '^', ms = 10, mec = 'red', mfc = 'orange', label = 'Average Speed')
plt.xlabel('Days')
plt.ylabel('Maximum Speed')
plt.title('Car Speed Measurement')
plt.legend()
plt.grid()
plt.show()
4. Question
x = np.arange(0,4*np.pi,0.1)
y = np.sin(x)
z = np.cos(x)
plt.plot(x,y, color = 'green', marker='o')
plt.plot(x,z, color = 'blue', marker = '*')
plt.xlabel('Sin and Cos Value From 0 to 4pi')
plt.ylabel('Sin(x) and Cos(x)')
plt.title('Sin And Cosine Wave')
plt.legend(['sin(X)','Cos(x)'])
plt.show()
5. Question
Languages =['Python', 'SQL', 'Java', 'C++', 'JavaScript']
Popularity = [56, 39, 34, 34, 29]
Security = [44 ,36 ,55, 50, 42]
plt.subplot(2,1,1)
plt.bar(Languages, Popularity, width=0.5, color = 'orange', align='center')
plt.xlabel('Languages')
plt.ylabel('Popularity')
plt.legend(['Popularity'])
plt.show()
plt.subplot(2,1,2)
plt.bar(Languages, Security, width=0.5, color = 'red', align='center')
plt.xlabel('Languages')
plt.ylabel('Security')
plt.legend(['Security'])
plt.show()
Horizontal Bar
Languages =['Python', 'SQL', 'Java', 'C++', 'JavaScript']
Popularity = [56, 39, 34, 34, 29]
Security = [44 ,36 ,55, 50, 42]
plt.subplot(2,1,1)
plt.barh(Languages, Popularity, color = 'g', align='center')
plt.xlabel('Languages')
plt.ylabel('Popularity')
plt.legend(['Popularity'])
plt.show()
plt.subplot(2,1,2)
plt.barh(Languages, Security, color = 'red', align='center')
plt.xlabel('Languages')
plt.ylabel('Security')
plt.legend(['Security'])
plt.show()