我在子图中绘制了多条线,但不是获得两条单独的线,而是仅显示最后调用的线。更令人困惑的是,该行仍然存在于图例中。
我试图通过在绘图功能中指定所需的轴来不同地设置子图,但这没有用。
alpha = 0.5
ylndPOS = [33, 33.25, 32.9375, 32.703125,33.27734375, 33.9580078125, 31.968505859375, 33.47637939453125, 29.857284545898438, 29.142963409423828,
27.10722255706787, 25.080416917800903, 25.310312688350677, 23.982734516263008, 25.237050887197256, 23.677788165397942,
24.258341124048457, 22.693755843036342, 23.520316882277257, 21.640237661707943, 21.980178246280957, 21.985133684710718,
21.48885026353304, 21.36663769764978, 20.024978273237334, 17.518733704928,
21.889050278696, 20.666787709022, 19.7500907817665, 20.062568086324873,
19.796926064743655, 17.84769454855774, 16.885770911418305,
14.914328183563729, 14.685746137672798, 13.514309603254599, 13.385732202440948,13.039299151830711,11.779474363873033,10.084605772904775,9.813454329678581,10.860090747258937,11.145068060444203,9.858801045333152,9.644100783999864,9.983075587999899,9.987306690999924,12.240480018249944,12.680360013687459,11.260270010265593,9.695202507699195,12.521401880774397,13.391051410580797,13.543288557935597,13.157466418451698,13.618099813838773,13.71357486037908,14.535181145284309,12.40138585896323,11.051039394222423,0]
xTime = ['T0', 'T1', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7', 'T8', 'T9', 'T10', 'T11', 'T12', 'T13', 'T14', 'T15', 'T16', 'T17', 'T18', 'T19', 'T20', 'T21', 'T22', 'T23', 'T24', 'T25', 'T26', 'T27', 'T28', 'T29', 'T30', 'T31', 'T32', 'T33', 'T34', 'T35', 'T36', 'T37', 'T38', 'T39', 'T40', 'T41', 'T42', 'T43', 'T44', 'T45', 'T46', 'T47', 'T48', 'T49', 'T50', 'T51', 'T52', 'T53', 'T54', 'T55', 'T56', 'T57', 'T58', 'T59','T60']
laxDP = ylndPOS
p = 0
for i in range(1, np.size(laxDP)-1):
laxDP[i] = laxDP[p]*alpha+(1-alpha)*laxDP[i]
p = p+1
plt.subplot(2,2,1)
plt.plot(xTime,ylndPOS,'green', label="Natural")
plt.plot(xTime,laxDP,'blue', label="Relaxed")
plt.title('Positiv lyndensitet',fontsize = font)
plt.ylabel('Antal lyn',fontsize = font)
plt.xticks(xTime, xTime, rotation=90, fontsize=6)
plt.legend()
我希望看到两行,但我只会看到“已放松”行。