Python 使用matplotlib打印地物时如何隐藏地物大小

Python 使用matplotlib打印地物时如何隐藏地物大小,python,matplotlib,Python,Matplotlib,我编写了以下函数以在Python/matplotlib中绘制混淆矩阵: def print_conf_mat(y_test, y_pred): conf_mat = confusion_matrix(y_test, y_pred) classes = ['Normal', 'Type 1', 'Type 2', 'Type 3', 'Type 4', 'Type 5', 'Type 6'] imshow(conf_mat, interpolation='nearest', cmap=cm.Blu

我编写了以下函数以在Python/matplotlib中绘制混淆矩阵:

def print_conf_mat(y_test, y_pred):
conf_mat = confusion_matrix(y_test, y_pred)
classes = ['Normal', 'Type 1', 'Type 2', 'Type 3', 'Type 4', 'Type 5', 'Type 6']
imshow(conf_mat, interpolation='nearest', cmap=cm.Blues)
print('Confusion matrix:')
colorbar()
tick_marks = arange(len(classes))
xticks(tick_marks, classes, rotation=45)
yticks(tick_marks, classes)
fmt = 'd'
thresh = conf_mat.max() / 2.
for i, j in product(range(conf_mat.shape[0]), range(conf_mat.shape[1])):
    text(j, i, format(conf_mat[i, j], fmt),
             horizontalalignment="center",
             color="white" if conf_mat[i, j] > thresh else "black")
xlabel('Predicted label')
ylabel('True label')
tight_layout()
figure()
show()
我得到的矩阵格式如下:

我想摆脱那句烦人的台词

<Figure size 432x288 with 0 Axes>


关于我是如何做到这一点的,有什么线索吗?

我在那张图片和你的代码中都看不到任何写有“”的行吗?我不太清楚你在问什么如果你删除了行
figure()
,那会发生什么,不管怎么说,这是没有用的?对不起。我上传了正确的图像。删除figure()是正确的解决方案。非常感谢你的光临!但是,当你真的想做
fig=plt.figure()
,然后可能做类似
fig.tight\u layout()
,这就成了一个问题