jcam77
jcam77

Reputation: 173

Matplotlib bar plot width only changing width of last bar

I have this barplot and changing with width value is only changing the width of the very last bar. I've attached the picture and code. Anyone know why?

indexes = np.arange(len(labels))
width = 2
pdb.set_trace()
plt.bar(indexes, values, width=2, color="blueviolet")
plt.xlabel("Phenotype identifier", fontdict=font)

enter image description here

Upvotes: 2

Views: 1105

Answers (1)

CT Zhu
CT Zhu

Reputation: 54330

Because your bars over laps with each other and your data happens to be monotonically increasing, see, if you (suppose indexes=range(10)):

plt.bar(indexes, range(10)[::-1], width=2, color="blueviolet")  #indexes should be indices

you'll get:

enter image description here

Upvotes: 3

Related Questions