import matplotlib.pyplot as plt
x = [2,4,6,8,10]
y=[3,9,11,2,6]
plt.bar(x,y,label ='Bars')
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('Bar Graph1')
plt.legend()
plt.show()
Output
Explanation:
Python library matplotlib.pyplot is used to draw the above chart. Two random variables x and y are taken with random values. The bar function plots a bar plot. The bar function takes 2 arguments i.e. x and y and a label variable gives the label to the plot. To name the axes xlabel and ylabel functions are used and to give the title to the plot the title function is used. To show the legend the legend function is used and finally to show the plot the show function.
Program:
Output
Explanation:
Python library matplotlib.pyplot is used to draw the above chart. Two random variables x and y are taken with random values. The bar function plots a bar plot. The bar function takes 2 arguments i.e. x and y and a label variable gives the label to the plot. To name the axes xlabel and ylabel functions are used and to give the title to the plot the title function is used. To show the legend the legend function is used and finally to show the plot the show function.
need an explanation for this answer? contact us directly to get an explanation for this answer