0

I have below python code to plot using matplotlib.

I need help on adding labels on top of each data bar.

import numpy as np

import matplotlib.pyplot as plt

N = 4
ind = np.arange(N) 
width = 0.25

xvals = [95.73,94.70,92.29,76.48]
bar1 = plt.bar(ind, xvals, width, color = 'r')

yvals = [78.47,76.65,63.61,41.58]
bar2 = plt.bar(ind+width, yvals, width, color='g')

zvals = [69.30,54.46,50.92,39.21]
bar3 = plt.bar(ind+width*2, zvals, width, color = 'b')

plt.xlabel("Teams")
plt.ylabel('Data (%)')
plt.title("Overall data")

plt.xticks(ind+width,['Team 1', 'Team 2', 'Team 3', 'Team 4'])

plt.legend( (bar1, bar2, bar3), ('Data 1', 'Data 2', 'Data 3') )


plt.show()
Woodford
  • 2,796
  • 1
  • 11
  • 25
Malik
  • 1

0 Answers0