【发布时间】:2021-05-07 01:07:04
【问题描述】:
问题:填写下面的代码以可视化所有 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', ha='center', va='center', rotation='vertical')
【问题讨论】:
-
错误告诉你问题是什么;
ax[i]是一个 numpy 数组,而 numpy 数组没有plot方法 -
请参阅this 文档下方的示例,其中有以下行:
f, (ax1, ax2) = plt.subplots(1, 2, sharey=True)。
标签: python numpy numpy-ndarray subplot