如何修复混淆矩阵图的Google Colab切割 [英] How to fix google colab cutting of plots of confusion matrices

查看:139
本文介绍了如何修复混淆矩阵图的Google Colab切割的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Google colab上创建一个混淆矩阵,但是一旦我将其绘制并尝试将其保存,该图的顶部和底部将被切除.有没有什么办法解决这一问题?

I'm trying to create a confusion matrix on google colab but once I plot it and try to save it the top and the bottom of the plot get cut off. Is there any way to fix this?

%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

Here is the result I'm getting. https://imgur.com/a/Y0RwHis

推荐答案

尝试还原回matplotlib 3.1.0

Try reverting back to matplotlib 3.1.0

!pip install matplotlib==3.1.0

或者您可以使用预发行版本(3.2.0rc)

Or you can use the pre-release version (3.2.0rc)

!pip install --pre -U matplotlib

这篇关于如何修复混淆矩阵图的Google Colab切割的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆