【问题标题】:How to increase size of heat map built using seaborn?如何增加使用 seaborn 构建的热图的大小?
【发布时间】:2021-01-28 16:39:25
【问题描述】:

下面是在热图中显示句子相似度的代码。最终图是一个 nxn 矩阵,其中每个条目 [i, j] 根据句子 i 和 j 的编码的内积进行着色。

def plot_similarity(labels, features, rotation):
  corr = np.inner(features, features)
  sns.set(font_scale=1.2)
  g = sns.heatmap(
      corr,
      xticklabels=labels,
      yticklabels=labels,
      vmin=0,
      vmax=1,
      cmap="YlOrRd")
  g.set_xticklabels(labels, rotation=rotation)
  g.set_title("Semantic Textual Similarity")

def run_and_plot(messages_):
  message_embeddings_ = embed(messages_)
  plot_similarity(messages_, message_embeddings_, 90)

热图工作正常,但是随着消息数量的增加,结果不再可见。有没有办法缩放热图?还是根据条目的数量增加大小?

谢谢!

【问题讨论】:

    标签: python python-3.x seaborn heatmap


    【解决方案1】:

    我刚刚找到了一种使用以下单个代码增加绘图大小的方法

    import matplotlib.pyplot as plt
    plt.subplots(figsize=(20,15))
    

    【讨论】:

      猜你喜欢
      • 2016-12-19
      • 1970-01-01
      • 2021-01-07
      • 2017-03-24
      • 1970-01-01
      • 2017-12-06
      • 1970-01-01
      • 1970-01-01
      • 2020-04-10
      相关资源
      最近更新 更多