Skip to content

Python code snippet – How to plotting bar on matplotlib?

import matplotlib.pyplot as plt 

data = [5., 25., 50., 20.]
plt.bar(range(len(data)),data)
plt.show()

// to set the thickness of a bar, we can set 'width'
// plt.bar(range(len(data)), data, width = 1.)
See also  Java code snippet - How to write a member of in latex?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.