Q. Write a program to create a horizontal bar chart from two data sequences as given below:
means [20, 35, 30, 35, 27]
stds = [2, 3, 4, 1, 2]
Make sure to show legends.
Answer :-
import matplotlib.pyplot as plt import numpy as np means = [20, 35, 30, 35, 27] stds = [2, 3, 4, 1, 2] indx = np.arange (len (means)) plt.barh(indx, means, color ='cyan', label = 'means') plt.barh(indx +0.25, stds, color = 'olive', label = "stds") plt.legend() plt.show()
Output :-
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )