[Matplotlib-users] How does the x coordinates work for plt.bar()?
Sreyan Chakravarty
sreyan32 at gmail.com
Fri Sep 6 15:32:03 EDT 2019
I am unable to understand how the plt.bar() function actually works.
Take the following code for example:
from collections import Countergrades = [83, 95, 91, 87, 70, 0, 85,
82, 100, 67, 73, 77, 0]
# Bucket grades by decile, but put 100 in with the 90shistogram =
Counter(min(grade // 10 * 10, 90) for grade in grades)
plt.bar([x + 5 for x in histogram.keys()], # Shift bars right by 5
histogram.values(), # Give each bar its correct height
10, # Give each bar a width of 10
edgecolor=(0, 0, 0)) # Black edges for each bar
What does it mean by shift bars by 5 in the plt.bar() call? Does it mean by
5 pixels? 5%? 5% of what?
These measurements make no sense. Can someone explain to me how this works?
--
Regards,
Sreyan Chakravarty
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20190907/0713d268/attachment-0001.html>
More information about the Matplotlib-users
mailing list