 # [Matplotlib-users] How does the x coordinates work for plt.bar()?

I am unable to understand how the plt.bar() function actually works.

Take the following code for example:

``````from collections import Counter
grades = [83, 95, 91, 87, 70, 0, 85, 82, 100, 67, 73, 77, 0]

# Bucket grades by decile, but put 100 in with the 90s

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

Five of the same units of your x-axis, which in this case, is points on someone’s grade.

-Paul

···

On Fri, Sep 6, 2019 at 12:32 PM Sreyan Chakravarty sreyan32@gmail.com wrote:

I am unable to understand how the plt.bar() function actually works.

Take the following code for example:

``````from collections import Counter
grades = [83, 95, 91, 87, 70, 0, 85, 82, 100, 67, 73, 77, 0]

# Bucket grades by decile, but put 100 in with the 90s

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

Matplotlib-users mailing list

Matplotlib-users@python.org

https://mail.python.org/mailman/listinfo/matplotlib-users