1

I have plot below figure.

enter image description here

I want to add text inside the bar like in below figure.

enter image description here

How to achieve this? I have seen people put text above bar, but not inside.

Below is my current code which needs to be completed.

from pylab import *
import re
matplotlib.rc('xtick', labelsize=16) 
matplotlib.rc('ytick', labelsize=16) 
plt.rcParams['font.size'] = 16
plt.rcParams['axes.labelsize'] = 16
plt.rcParams['xtick.labelsize'] = 16
plt.rcParams['ytick.labelsize'] = 16
plt.rcParams['legend.fontsize'] = 16
rc('font',family='Arial')


fig, ax = plt.subplots(figsize=(5,4))
x = array([2.2,4.4])
a = array([1,2])
b = array([1,2])
c = array([1,2])
total_width, n = 1, 3
width = total_width / n
x = x - width*1.5


xmarks=[2.2,4.4]

plt.xticks(xmarks)
xx=plt.bar(x, a,  width=width, color='r',alpha=0.5,label='0%')
xy=plt.bar(x + width, b, width=width, color='b',alpha=0.5,label='60%')
xz=plt.bar(x + 2 * width, c, width=width,color='g', alpha=0.5,label='100%')



leg = ax.legend([xx, xy,xz], 
            ("0%", "60%",'100%'),
            title="IOTs replacement\nwith FAC",
            loc='upper left')
leg.get_frame().set_alpha(0.0)
plt.show()
user3737702
  • 591
  • 1
  • 10
  • 17

0 Answers0