私のJupyterノートには次のコードがあります。私は今までインターネットで見つかった人物の姿を変えるいくつかの方法を試みましたが、何も動作していないようです。また、オブジェクトはmatplotlibの中で生成され、変更された方法は、本当にとにかく私には意味がありませんので、私は必ずどこ次に行きませんよ...Matplotlib:与えられたコードレイアウトの図形を増やすためのフォーマット
とにかく、私のコードはスタンドのとおりです。
from sklearn.metrics import confusion_matrix
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
def plot_confusion_matrix(cm, title='Confusion matrix',fontsize=8, names=None,cmap=plt.cm.Blues):
plt.imshow(cm, interpolation='nearest', cmap=cmap)
plt.title(title)
plt.colorbar()
for i in range(cm.shape[0]):
for j in range(cm.shape[1]):
plt.text(i, j, str(cm[i, j]), fontsize=fontsize)
if names != None:
tick_marks = np.arange(len(names))
plt.xticks(tick_marks, names)
plt.yticks(tick_marks, names)
plt.tight_layout()
plt.ylabel('True label')
plt.xlabel('Predicted label')
confusion_matrix_path = 'mnist_cnn/main_project/CNN_Completed_Models/mnist_cnn_C_confusion.npy'
cmat = np.load(confusion_matrix_path)
plot_confusion_matrix(cmat,"MNIST Net C: Confusion Matrix",fontsize=8, names=[0,1,2,3,4,5,6,7,8,9])
plt.figure(figsize=(20,20)) <----- This Line Here
plt.show()
plt.figure(figsize=(20,20))
行は何もしません。私が見つけた多くの修正もありません。このプロットの寸法を変更するにはどうすればいいですか?
死んだpngの代わりに。 – tacaswell
あなたは 'pyplot'の状態マシンに問題があり、それをあなたのプロット方法にプロットするためにどの数字を渡すのかを '現在のFigure'というグローバルな状態に頼っています。代わりに 'Axes'オブジェクトを' plot_confusion_matrix'に渡すべきです。 http://matplotlib.org/faq/usage_faq.html#coding-styles – tacaswell
を参照し、 '' plt.figure'は新しい図形を作成します(http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.figure )既存のFigureのサイズを変更しません。 – tacaswell