如何修复Google Colab切割混乱矩阵图

问题描述 投票:1回答:1

我正在尝试在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个回答
0
投票

尝试还原回matplotlib 3.1.0

!pip install matplotlib==3.1.0
© www.soinside.com 2019 - 2024. All rights reserved.