Reputation: 10033
This is my code:
Y1 = a1_points['pontos_num']
Y2 = a1_points['RollingAvg']
Y3 = a2_points['pontos_num']
Y4 = a2_points['RollingAvg']
X = max(len(Y1),len(Y3))
plt.plot(range(1,X), Y1, label='Vitor Gabriel Gameweek Points', lw=0.5, ls='--')
plt.plot(range(1,X), Y2, label='Vitor Gabriel Rolling Average', lw=3, color=Blue)
plt.plot(range(1,X), Y3, label='Luis Henrique Gameweek Points', lw=0.5, ls='--', color=Amber)
plt.plot(range(1,X), Y4, label='Luis Henrique Rolling Average', lw=3, color=Amber)
plt.xlabel('Rodada')
plt.ylabel('Pontos')
plt.title('Vitor Gabriel vs. Luis Henrique')
plt.xlim(1,X-2)
plt.ylim(0,15)
plt.legend(loc=2, frameon=False);
plt.show()
how do I fix the error?
Upvotes: 0
Views: 75
Reputation: 29635
The problem is that range(1,X)
doesn't have the same length than Y1 and/or Y3 because the way you build it. If both a1_points
and a2_points
have the same same length, then range(1,X)
should be replaced by range(1,X+1)
. But in the case a1_points
and a2_points
don't have the same length, then it safer to do:
plt.plot(range(1, len(Yn)+1), Yn, ...)
for each n is 1, 2, 3 or 4 in your case
Upvotes: 1