【发布时间】:2021-03-14 01:38:59
【问题描述】:
我不能在热图上叠加绘图(热图应该是海底绘制的)。
这是我的小数据示例
mat = [
[1,2,3,1,1,2,2,1,5],
[3,2,2,1,1,2,2,1,5],
[6,2,8,2,1,0,0,4,2],
[3,1,2,3,1,2,4,1,4],
[3,1,9,4,1,3,2,1,5],
]
iters = [1, 2, 8, 16, 32, 128, 256, 512, 1024] # iterations for x-axis
names = [1, 2, 3, 4, 5] # 5 clusters
maxim = [1, 1, 3, 5, 1, 4, 4, 5, 1] # maximum cluster at iter
conc = ["dog", "spoon", "table", "bike", "hat", "hat", "porch", "sweater", "bird"] # maximum concept in cluster for annotation
和绘图
def plot_cluster_heatmap_over_iters(iter_scores, iters, cluster_names, maximum_cluster, max_concepts):
import seaborn as sns
ax = sns.heatmap(iter_scores, cmap="gist_yarg")
plt.xticks(range(len(iters)), iters, rotation=90);
plt.yticks(range(len(cluster_names)), cluster_names, rotation=0);
ax.set_yticklabels(ax.get_yticks(), size=7)
plt.plot(iters, maximum_cluster, marker='o', )
#annotate markers
prev_cl = None
for it, ci, cl in zip(iters, maximum_cluster, max_concepts):
if prev_cl is None or prev_cl != cl:
plt.annotate(cl, (it, ci), rotation=40, size=12)
prev_cl = cl
plt.show()
plot_cluster_heatmap_over_iters(mat, iters, names, maxim, conc)
但我有类似的错误
ValueError: Image size of 76240x871 pixels is too large. It must be less than 2^16 in each direction.
有人可以帮助我改进我的代码,使其正常工作并完成工作(我敢打赌几乎没有问题)吗? 谢谢
【问题讨论】:
标签: python matplotlib seaborn