问题描述
问题:填写下面的代码以可视化所有 100 种蛋白质表达。
这是我的代码。我不知道为什么它一直显示 'numpy.ndarray' 对象没有属性 'plot'。
fig,ax = plt.subplots(10,10,figsize=(15,15),sharex=True,sharey=True)
for i,protein in enumerate(PROTEIN_NAMES):
ax[i].plot(young_df[i],label="Young",alpha=0.6)
ax[i].plot(old_df[i],label="Old",alpha=0.6)
continue
fig.text(0.5,0.04,'Sample number',ha='center',va='center')
fig.text(0.06,0.5,'Expression Value',va='center',rotation='vertical')
解决方法
我认为问题在于,斧头是二维图,因此您必须像这样将 protein
添加到循环中
fig,ax = plt.subplots(10,10,figsize=(15,15),sharex=True,sharey=True)
for i,protein in enumerate(PROTEIN_NAMES):
ax[i,protein].plot(young_df[i],label="Young",alpha=0.6)
ax[i,protein].plot(old_df[i],label="Old",alpha=0.6)
continue
fig.text(0.5,0.04,'Sample number',ha='center',va='center')
fig.text(0.06,0.5,'Expression Value',va='center',rotation='vertical')