【发布时间】:2017-03-17 16:22:22
【问题描述】:
我正在尝试创建一个漂亮的图,它加入一个 4x4 网格的子图(使用 gridspec 放置,每个子图是 8x8 像素)。我一直在努力让情节之间的间距与我试图告诉它做的事情相匹配。我想问题是由于在图的右侧绘制了一个颜色条,并调整了图中图的位置以适应。但是,即使没有包含彩条,这个问题似乎也会出现,这让我更加困惑。它也可能与边距有关。下面显示的图像由相关代码生成。正如你所看到的,我试图让地块之间的空间变为零,但它似乎不起作用。谁能给点建议?
fig = plt.figure('W Heat Map', (18., 15.))
gs = gridspec.GridSpec(4,4)
gs.update(wspace=0., hspace=0.)
for index in indices:
loc = (i,j) #determined by the code
ax = plt.subplot(gs[loc])
c = ax.pcolor(physHeatArr[index,:,:], vmin=0, vmax=1500)
# take off axes
ax.axis('off')
ax.set_aspect('equal')
fig.subplots_adjust(right=0.8,top=0.9,bottom=0.1)
cbar_ax = heatFig.add_axes([0.85, 0.15, 0.05, 0.7])
cbar = heatFig.colorbar(c, cax=cbar_ax)
cbar_ax.tick_params(labelsize=16)
fig.savefig("heatMap.jpg")
类似地,在没有颜色条的情况下制作正方形:
fig = plt.figure('W Heat Map', (15., 15.))
gs = gridspec.GridSpec(4,4)
gs.update(wspace=0., hspace=0.)
for index in indices:
loc = (i,j) #determined by the code
ax = plt.subplot(gs[loc])
c = ax.pcolor(physHeatArr[index,:,:], vmin=0, vmax=400, cmap=plt.get_cmap("Reds_r"))
# take off axes
ax.axis('off')
ax.set_aspect('equal')
fig.savefig("heatMap.jpg")
【问题讨论】:
标签: python matplotlib plot