子图正在被Matplotlib切断

时间:2017-08-17 03:25:20

标签: python matplotlib plot figure subplot

我正在编写正在编写的绘图程序。该程序基本上绘制了一个图中相同大小的4个子图。 for循环使用plt.subplot()保存这些数字中的大约100个。我遇到的问题是,对于超过一半的数字,底部的2个子图用灰色带切断,不仅仅是轴标签,而是数字本身。我尝试调整情节的粗体,但实际上使它变大会使问题变得更糟。使figsize更小实际上摆脱灰色带但伤害轴标签。我在下面发布我的代码。我使用的是更旧版本的matplotlib(1.5.1)所以也许这就是问题,但说实话我以前从未见过这个。这几乎就像这个数字的最后一点没有保存。

我的代码生成数据发布如下,任何帮助将不胜感激。我希望我可以发布一个数字,但我没有足够的堆栈溢出点= P

crop = np.s_[inds_up[lbl]:inds_down[lbl], inds_left[lbl]:inds_right[lbl]]
saveloc = generate_saveloc(inds_up[lbl],inds_down[lbl], inds_left[lbl],inds_right[lbl], granule.save_folder)

fig = plt.figure(figsize=(10,6))
fig.suptitle("Diagnostic at Crop %d : %d, %d : %d" % (inds_up[lbl],inds_down[lbl], inds_left[lbl],inds_right[lbl]))

vmin = 271.15 if np.nanmin(layers['sst'][crop][layers['spt'][crop]!=3]) < 271.15 else np.nanmin(layers['sst'][crop][layers['spt'][crop]!=3])
vmax = np.nanmax(layers['sst'][crop][layers['spt'][crop]!=3])

ax1 = plt.subplot(221)
ax1.set_title("Sea Surface Temperature", fontsize=10)
ax1.axis('off')
img1 = ax1.imshow(layers['sst'][crop],vmin=vmin,vmax=vmax)
div1 = make_axes_locatable(ax1)
cax1 = div1.append_axes("right", size="5%", pad=0.05)
cbar1 = plt.colorbar(img1, cax=cax1)

ax2 = plt.subplot(222)
ax2.set_title('Albedo', fontsize=10)
ax2.axis('off')
img1 = ax2.imshow(layers['albedo'][crop], vmin=0, vmax=10, cmap='gray')
div1 = make_axes_locatable(ax2)
cax1 = div1.append_axes("right", size="5%", pad=0.05)
cbar1 = plt.colorbar(img1, cax=cax1)

ax2 = plt.subplot(223)
ax2.set_title('SST Gradient Magnitude', fontsize=10)
ax2.axis('off')
img1 = ax2.imshow(layers['gradient'][crop],vmin=0, vmax=0.5, cmap='gray')
div1 = make_axes_locatable(ax2)
cax1 = div1.append_axes("right", size="5%", pad=0.05)
cbar1 = plt.colorbar(img1, cax=cax1)


ticklabels = ['Agreed Clear' ,'SPT Cloud','Clear Front','SPT Clear', 'Agreed Cloud','Cloud Front']
ax2 = plt.subplot(224)
ax2.set_title('Questionable', fontsize=10)
ax2.axis('off')
img1 = ax2.imshow(layers['overlay'][crop],cmap=cmap_overlay,vmin=-0.5,vmax=5.5)
div1 = make_axes_locatable(ax2)
cax1 = div1.append_axes("right", size="5%", pad=0.05)
cbar1 = plt.colorbar(img1, cax=cax1,ticks=np.linspace(0,5,6))
cbar1.set_ticklabels(ticklabels)

#plt.tight_layout()
plt.savefig(saveloc, bbox_layout='tight')
plt.savefig(saveloc)
plt.close()

更新: 事实证明这个问题与matplotlib或savefig无关。我正在使用sshfs从我的计算机上的单独服务器查看文件。当我用eog查看它们时,灰色的乐队会出现,但是当我将这些数字上传到谷歌驱动器时,灰色乐队就不存在了。这表明问题在于我与服务器的连接。感谢您的回复。

0 个答案:

没有答案
相关问题