Sudarshan Singh
Sudarshan Singh

Reputation: 57

How to plot bar graph in python

I have below data in dictionary and want to plot bar with label('AT','BT','CT','DT','ET'). it is okay if only 3 digit after decimal considered.

{0: 0, 1: 19.091883092036781, 2: 35.317606562921746, 3: 22.122563913375465, 4: 37.961028320110699, 5: 36.541670802198659}

Upvotes: 2

Views: 1621

Answers (1)

Yunhe
Yunhe

Reputation: 665

Try this using matplotlib:

import matplotlib.pyplot as plt
data = {0: 0, 1: 19.091883092036781, 2: 35.317606562921746, 3: 22.122563913375465, 4: 37.961028320110699, 5: 36.541670802198659}
bar_width = 0.8
plt.bar([x for x in data], [data[x] for x in data], bar_width)
plt.xticks([x + bar_width/2 for x in data], (' ', 'AT','BT','CT','DT','ET'))  

enter image description here

Upvotes: 3

Related Questions