Q. What changes will you make to the code so that the bars are visible for all four points? But do keep in mind that the x-axis must begin from the point -3.
import matplotlib.pyplot as plt
a = [3, 6, 9, 12]
b = [30, 48, 54, 48]
plt.xlim(-3, 5)
plt.bar(a,b)
plt.show()
Answer :-
If we change the limits of X-axis so that all the points being plotted fall in the range of limits, all values will show. Thus, we have changes the limits from -3 to 15, in place of -3 to 5.
import matplotlib.pyplot as plt a = [3, 6, 9, 12] b = [30, 48, 54, 48] plt.xlim(-3, 15) plt.bar(a,b) plt.show()
Output :-
How to count the digits keys value in code
ReplyDeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )