G = [500, 600]
V_cel = [[0.5061622703106294, 0.018464827637910804], [0.5109806104259279, 0.020619347874867924]]
I_cel = [[0. 0.35938438] [0. 0.4335135 ]]
P_cel = [[0.0, 0.006635970540228099], [0.0, 0.008938765665079252]]
plt.figure(1,figsize=(10,3))
plt.subplot(121)
for i in G:
for t in list(zip(V_cel, I_cel)):
plt.plot(*t, label='%s W/m$^{2}$' % i)
plt.legend()
plt.axis([0, 0.7, 0, 0.9])
plt.subplot(122)
for i in G:
for t in list(zip(V_cel, P_cel)):
plt.plot(*t, label='%s W/m$^{2}$' % i)
plt.legend()
plt.axis([0, 0.7, 0, 0.4])
plt.suptitle("I-V & P-V curves of PV cell for given STC data", fontsize=20)
plt.rc('font',family='Times New Roman')
plt.savefig('STC_I_V_curve')
plt.show()
** output is: I have plotted two subplots and it is fine. Problem is with legends. Both should show a list of ten legends only. Because, V_cel
and I_cel
both have [10 lists, each list with 1000 values]. Instead, both plots are showing 100 legends. Please, see the attached plot. I want it show ten legends [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]
only.Some where the error is.
** Output after including the changes as per SpghttCd
code, which is accepted as answer