我正在使用财务数据绘制散点图。 x-y轴是资产的百分比变化,我希望颜色对应当天交易量的总和。我还将这些值归入一周中的几天,并为它们分配了特定的符号。
plt.figure()
plt.style.use('seaborn')
fig, ax = plt.subplots()
z1 = merged_monday['Total Volume Tesla & NASDAQ']
z2 = merged_tuesday['Total Volume Tesla & NASDAQ']
z3 = merged_wednesday['Total Volume Tesla & NASDAQ']
z4 = merged_thursday['Total Volume Tesla & NASDAQ']
z5 = merged_friday['Total Volume Tesla & NASDAQ']
zs = np.concatenate([z1, z2, z3, z4, z5], axis=0)
min_, max_ = zs.min(), zs.max()
mon_scat = plt.scatter(merged_monday['Percentage Change NASDAQ'], merged_monday['Percentage Change Tesla'], c=z1,cmap='viridis_r',marker= 'o', label = 'Monday', edgecolors = 'black')
plt.clim(min_, max_)
tue_scat = plt.scatter(merged_tuesday['Percentage Change NASDAQ'], merged_tuesday['Percentage Change Tesla'],c=z2, marker= 'x', label = 'Tuesday')
plt.clim(min_, max_)
wed_scat = plt.scatter(merged_wednesday['Percentage Change NASDAQ'], merged_wednesday['Percentage Change Tesla'],c=z3,cmap='viridis_r',marker= 'v', label = 'Wednesday', edgecolors = 'black', alpha = '0.6')
plt.clim(min_, max_)
thurs_scat = plt.scatter(merged_thursday['Percentage Change NASDAQ'], merged_thursday['Percentage Change Tesla'],c=z4,marker= 'd', label = 'Thursday', edgecolors = 'black')
plt.clim(min_, max_)
fri_scat = plt.scatter(merged_friday['Percentage Change NASDAQ'], merged_friday['Percentage Change Tesla'],c=z5,marker= 's', label = 'Friday', edgecolors = 'black', alpha = '0.6')
plt.clim(min_, max_)
plt.colorbar().set_label('Comb. Volume Traded',rotation=270)
ax.set_xlabel("Percentage Change NASDAQ (Decimal)")
ax.set_ylabel("Percentage Change Tesla (Decimal)")
plt.axvline(0, c = (0.5, 0.5, 0.5), ls= '--')
plt.axhline(0, c = (0.5, 0.5, 0.5), ls= '--')
ax.legend()
plt.savefig('Tesla_NASDAQ_Scatter.ps')
如何将我的颜色分配给我的z值,我尝试了很多方法,但是不断抛出此错误?
numpy.core._exceptions.UFuncTypeError: ufunc 'clip' did not contain a loop with signature matching types (dtype('<U11'), dtype('<U11'), dtype('<U11')) -> dtype('<U11')