小编psk*_*shu的帖子

使用颜色条时如何保持图像大小?

我正在尝试并排绘制同一图像的两个版本。当我绘制其中一张图像没有颜色条的图形时,它似乎具有正确的尺寸:

没有颜色条

但是当我向左侧图像添加颜色条时,它会以某种方式缩小图像:

缩小图像

这是我注释掉颜色条行的代码:

def plot_amaps(self, anisotropy_map, parallel):
        timepoint = self.t * self.timestep
        amap_directory = self.directory + "amaps/"
        fig = plt.figure(facecolor='w', dpi=180)

        ax1 = fig.add_subplot(121)
        fig.subplots_adjust(top=0.85)
        ax1.grid(False)
        txt = "Mean(r) = %.3f SD(r)= %.3f t=%dmin"
        txt = txt %(self.mean, self.sd, timepoint)
        ax1.set_title(txt)

        amap = ax1.imshow(anisotropy_map, cmap="jet", clim = self.clim)
        #divider = make_axes_locatable(ax1)
        #cax = divider.append_axes('right', size='5%', pad=0.05)
        #fig.colorbar(amap, cax=cax)

        ax2 = fig.add_subplot(122)
        ax2.set_title("Intensity image", fontsize=10)
        ax2.imshow(parallel, cmap="gray")
        ax2.grid(False)
        ax1.axis('off')
        ax2.axis('off')

        if self.save is True:
            self.make_plot_dir(amap_directory)
            name = self.cell + "_time_"+str(timepoint)
            plt.savefig(amap_directory+name+self.saveformat, …
Run Code Online (Sandbox Code Playgroud)

python plot image matplotlib colorbar

5
推荐指数
1
解决办法
4213
查看次数

标签 统计

colorbar ×1

image ×1

matplotlib ×1

plot ×1

python ×1