1

Can someone help me add Y-values to my bars. I have tried but no luck. And what would you recommend to make this code look cleaner? I feel like it can be improved but I'm still in the learning stage.

import matplotlib.pyplot as plt
import numpy as np

#style
plt.style.use("seaborn-colorblind")

# bar width
bar_width = 0.25

# data
months = ['April', 'May', 'June']
application = [18, 44, 7]
infrastructure = [27, 36, 20]

# convert months to array
months_array = np.arange(len(months))

# y labels
plt.ylabel('# of Errors\n', fontsize=14, fontweight='bold')

# add minor ticks on y axis
yticks = np.arange(0,45,5)
plt.yticks(yticks)

# graph title
plt.title("Fatal Errors from April 23rd - June 11th", fontsize=18,            fontweight='bold')

# bars names
plt.xticks(months_array + bar_width-0.125, months, fontweight='bold')


# bars
plt.bar(months_array, application, width=bar_width, color='#5cbae6',     edgecolor='white', label='Application')
plt.bar(months_array + bar_width, infrastructure, width=bar_width,     color='#b6d957', edgecolor='white', label='Infrastructure')

# legend
plt.legend()

# show graph
plt.show()

This is what I currently have: Click here for picture

But I want something like this without percentage and values inside the bars: Click here for picture - not my picture

tonie
  • 11
  • 2

0 Answers0