I am having four different lists-
x=['18ww25', '18ww27', '18ww28', '18ww28.1', '18ww29', '18ww29.1', '18ww29.2']
r=[[27, 27, 27, 27, 27, 27, 27, 43, 43, 43],
[18, 18, 20, 23, 30, 30, 30, 16, 16, 16],
[24, 25, 28, 32, 39, 39, 43, 74, 74, 74],
[43, 43, 44, 44, 43, 45, 45, 1, 1, 1],
[0, 0, 0, 0, 0, 0, 0, 42, 42, 42],
[14, 14, 16, 16, 16, 17, 17, 57, 57, 57],
[14, 14, 14, 14, 14, 14, 14, 5, 5, 5],
[0, 0, 0, 0, 0, 0, 0, 4, 4, 4],
[8, 8, 8, 8, 8, 8, 8, 3, 3, 3]]
tableau20 = [(31, 119, 180), (174, 199, 232), (255, 127, 14), (255, 187, 120),
(44, 160, 44), (152, 223, 138), (214, 39, 40), (255, 152, 150),
(148, 103, 189)]
l=['PIF', 'ucode patch mem', 'ucode patch match', 'pcode patch mem',
'pcode global patch match', 'pcode local patch match', 'vcode patch mem',
'vcode global patch match', 'vcode local patch match']
where x and r are the lists that are used for plotting lines. Every list in r list is plotted against x list. tableau20 is a list that contains the colors in the RGB format. "l" is a list that is the text labels for the different lines which is kept in the same seuence in which the line is plotted.
Now i am plotting a graph using the below code-
for i in range(len(tableau20)): #Scale the RGB values to the [0, 1] range, which is the format matplotlib accepts.
r, g, b = tableau20[i]
tableau20[i] = (r / 255., g / 255., b / 255.)
fig = plt.figure(figsize=(8,4)) #height x width
ax = plt.subplot(1,1,1)
ax.spines["top"].set_visible(False)
ax.spines["bottom"].set_visible(False)
ax.spines["right"].set_visible(False)
ax.spines["left"].set_visible(False)
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
maximum=maxi(r)
print(maximum)
plt.ylabel("UTILIZATION [%]",fontsize=7)
plt.xlabel("WORKING WEEK (WW)",fontsize=7)
plt.ylim(0,maximum+11)
plt.yticks(range(0, maximum+11, 10), [str(x) + "%" for x in range(0, maximum+11, 10)], fontsize=4)
plt.tick_params(axis='both', which='both', bottom=False, top=False, labelbottom=True, left=False, right=False, labelleft=True,labelsize=4)
title="SKX "+gt+" PATCH UTILIZATION"
plt.title(title,fontsize=9)
for i in range(len(r)):
ax.plot(x,r[i],color=tableau20[i])
textno=0
for line, name in zip(ax.lines, l):
y = line.get_ydata()[-1]
ax.annotate(l[textno], xy=(.95,y), xytext=(3,0), color=tableau20[textno],xycoords = ax.get_yaxis_transform(), textcoords="offset points",size=7, va="center")
textno+=1