首页 > 解决方案 > 使用列表迭代的子图标题

问题描述

我试图从 Arduino 绘制一些数据,在那里我制作了一个列表,它跟踪它正在执行的数据点。这适用于数据,但是,我无法创建子图标题,因为它插入数据点,而不是字符串名称本身。任何方式来实现它,例如,标题可以是数据点的字符串。'相关x'?

a = [x,y,z] 

for k in a:
t,y_t = kryds(k,kor)  

# creating grid for subplots
fig = plt.figure()
fig.set_figheight(5)
fig.set_figwidth(8.5)

ax1 = plt.subplot2grid(shape=(14, 3), loc=(0, 0), colspan=3,rowspan=3)
ax2 = plt.subplot2grid(shape=(14, 3), loc=(3, 0), colspan=3,rowspan=3)
ax3 = plt.subplot2grid(shape=(14, 3), loc=(8, 0), rowspan=6,colspan=3)

# plotting subplots
ax1.plot(range(len(k)), k)
ax1.grid(True)
ax1.set_ylabel('acceleration[g]')

ax2.plot(range(len(kor)), kor)
ax2.grid(True)
ax2.set_xlabel('Sample nr.')
ax2.set_ylabel('korrelations signal')

ax3.plot(t, y_t,'r.')
ax3.grid(True)
ax3.set_ylabel('Krydskorrelation')
ax3.set_xlabel('Forskydning [samples]')
fig.suptitle(f'correlation {k}')
plt.show()

标签: listiterationtitlef-string

解决方案


推荐阅读