How to merge common bars and labels in matplotlib bar plot

Viewed 75

I want to create a barplot with these specifities:

  • No space between bars
  • Combine unique values of the common values of bars

There is no similar question!

import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_axes([0,0,1,1])
langs = [1,2,3,4,5,6,7,8,9,10]
students = [10,10,20,20,20,20,30,30,15,15]
ax.bar(langs,students)
plt.savefig('barplot.pdf')

the output of code

ax.bar(langs,students,width = 1.0)

width = 1.0 is NOT EXACTLY working. There is little gaps, too.

I want to create the exact output below.

enter image description here

How can I do this?

0 Answers
Related