import matplotlib
import matplotlib.pyplot as plt
import numpy as np
colors = dict()
colors['sats'] = 'b'
colors['cache'] = 'orange'
colors['3h'] = 'k'
colors['memory'] = 'g'
colors['integer'] = 'r'
#####################################
sz = np.array([ 2., 4., 6., 8.])
t1 = np.array([ 5.9718688 , 13.23303584, 23.9000157 , 37.94884449])
t2 = np.array([ 7.38123836, 16.45442501, 29.56201748, 46.60925727])
t3 = np.array([ 8.87223103, 19.89443438, 36.27273578, 57.65372517])
t4 = np.array([ 9.88902238, 22.11467593, 40.2324561 , 63.90151877])
t4 -= t3
t3 -= t2
t2 -= t1
plt.bar(sz, t1, color=colors['sats'], edgecolor='white', label="SATS")
plt.bar(sz, t2, bottom=np.array(t1), color=colors['cache'], edgecolor='white', label="Caching values")
plt.bar(sz, t3, bottom=np.array(t1)+np.array(t2), color=colors['memory'], edgecolor='white', label="Optimizing memory access")
plt.bar(sz, t4, bottom=np.array(t1)+np.array(t2)+np.array(t3), color=colors['integer'], edgecolor='white', label="Integer SATS")
plt.ylim(top=70)
plt.xlabel('Filter radius')
plt.ylabel('Cumulative speedup ratio')
plt.legend()
plt.savefig("benchmark-cpu-relativit.pdf", transparent = True, bbox_inches = 'tight', pad_inches = 0)
plt.close()
So I want to add the total value on top of the bars. For example, first bar should have 10, second bar should have 22, ...
I tried barh
but I get error TypeError: bar() got multiple values for keyword argument 'bottom'