【问题标题】:How to fix google colab cutting of plots of confusion matrices如何修复混淆矩阵图的谷歌colab切割
【发布时间】:2019-12-02 11:10:31
【问题描述】:

我正在尝试在 google colab 上创建一个混淆矩阵,但是一旦我绘制它并尝试将它保存起来,绘图的顶部和底部就会被切断。有没有什么办法解决这一问题?

%matplotlib inline
import seaborn as sn
import pandas as pd
import matplotlib.pyplot as plt
from google.colab import files
array =  [[1, 0, 0], 
       [0, 1, 0.0101], 
      [0, 0, 0.9898]]
df_cm = pd.DataFrame(array, index = ["REM", "Wake", "NREM"],
              columns = ["REM", "Wake", "NREM"],)
plt.figure(figsize = (10,7))
sn.heatmap(df_cm, annot=True, cmap="YlGnBu", linewidths=0.5)
plt.savefig("Fid.pdf", bbox_inches='tight')
files.download("Fid.pdf")

这是我得到的结果。 https://imgur.com/a/Y0RwHis

【问题讨论】:

  • 我运行了你的代码,它对我来说非常好

标签: python google-colaboratory confusion-matrix


【解决方案1】:

尝试恢复到 matplotlib 3.1.0

!pip install matplotlib==3.1.0

或者你可以使用预发布版本(3.2.0rc)

!pip install --pre -U matplotlib

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-02-23
    • 2020-09-19
    • 2016-06-04
    • 1970-01-01
    • 2019-09-09
    • 1970-01-01
    • 2017-03-20
    相关资源
    最近更新 更多