Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何修复混淆矩阵图的google colab切割_Python_Google Colaboratory_Confusion Matrix - Fatal编程技术网

Python 如何修复混淆矩阵图的google colab切割

Python 如何修复混淆矩阵图的google colab切割,python,google-colaboratory,confusion-matrix,Python,Google Colaboratory,Confusion Matrix,我试图在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.98

我试图在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")

这是我得到的结果

尝试恢复到matplotlib 3.1.0

!pip install matplotlib==3.1.0
也可以使用预发布版本(3.2.0rc)


我运行了你的代码,它对我来说非常好
!pip install --pre -U matplotlib