【发布时间】:2014-05-03 07:48:52
【问题描述】:
我有四个混淆矩阵要在 pyplot 中绘制。以下是我的代码和结果图片:
confmatmap=cm.YlOrBr
fig = plt.figure()
plt.clf()
ax = fig.add_subplot(221)
ax.set_aspect(1)
res = ax.imshow(np.array(norm_conf_1), cmap=confmatmap, interpolation='nearest')
plt.xticks(range(2), ['T', 'F']); plt.yticks(range(2), ['T', 'F'])
ax = fig.add_subplot(222)
ax.set_aspect(1)
res = ax.imshow(np.array(norm_conf_2), cmap=confmatmap, interpolation='nearest')
plt.xticks(range(2), ['','']);plt.yticks(range(2), ['','']);
ax = fig.add_subplot(223)
ax.set_aspect(1)
res = ax.imshow(np.array(norm_conf_3), cmap=confmatmap, interpolation='nearest')
plt.xticks(range(2), ['','']);plt.yticks(range(2), ['','']);
ax = fig.add_subplot(224)
ax.set_aspect(1)
res = ax.imshow(np.array(norm_conf_4![enter image description here][2]), cmap=confmatmap, interpolation='nearest')
plt.xticks(range(2), ['','']);plt.yticks(range(2), ['','']);
fig.subplots_adjust(left=0, bottom=0, right=1, top=1,wspace=0, hspace=0.1)
但是左子图和右子图之间的差距对我来说太大了。我希望垂直和水平间隙的大小大致为一个字符。
我可以通过将hspace 设置为非常小的值来缩小上下子图之间的差距,但wspace 不起作用。
我认为这可能是因为子图有一些空白部分是白色的。
如何缩小此处与任何指定值的差距?
【问题讨论】:
标签: python matplotlib plot subplot