【发布时间】:2020-12-12 13:22:18
【问题描述】:
我从此处提供的示例进行扩展。 Heatmap with circles indicating size of population
但是,我不知道如何将 NumPy 数组与 PathCollector 一起使用来创建一个热图,该热图生成一个包含 20 个变量(Term)的单列,其中的圆圈表示大小(Number_Protein)和颜色(P_value_abs)。
这是我迄今为止所得到的,任何帮助将不胜感激。
ylabels = Shared["Term"]
xlabels = ["Overlap"]
x, y = np.meshgrid(1, 20)
s = Shared["Number_Protein"]
c = Shared["P_value_abs"]
fig, ax = plt.subplots()
R = s/s.max()/2
circles = [plt.Circle((j,i), radius=r) for r, j, i in zip(R, x, y)]
col = PatchCollection(circles, array=c, cmap="coolwarm")
ax.add_collection(col)
ax.set(xticklabels=xlabels, yticklabels=ylabels)
fig.colorbar(col)
plt.show()
这个问题已经回答了,但我只是想展示最终产品,以防有人好奇。
【问题讨论】:
-
不确定如何发布没有图片的数据框?
-
你可以添加
print(Shared.to_dict())的输出
标签: python numpy matplotlib heatmap