Skip to content
Snippets Groups Projects
Commit 8bf13bc0 authored by David Johansen's avatar David Johansen
Browse files

fixed issue with uneven white spacing due to the colorbar

parent 2a8b7ed0
No related branches found
No related tags found
1 merge request!124Viz add colorbar
This commit is part of merge request !124. Comments created here will be created in the context of that merge request.
......@@ -192,9 +192,15 @@ def slices(
ax.axis("off")
if cbar:
fig.tight_layout()
norm = matplotlib.colors.Normalize(vmin=new_vmin, vmax=new_vmax, clip=True)
mappable = matplotlib.cm.ScalarMappable(norm=norm, cmap=cmap)
fig.colorbar(mappable=mappable, ax=np.atleast_1d(axs[0])[-1], orientation='vertical')
# Figure coordinates of top-right axis
tr_pos = np.atleast_1d(axs[0])[-1].get_position()
# The width is divided by ncols to make it the same relative size to the images
cbar_ax = fig.add_axes([tr_pos.x1 + 0.05/ncols, tr_pos.y0, 0.05/ncols, tr_pos.height])
fig.colorbar(mappable=mappable, cax=cbar_ax, orientation='vertical')
if show:
plt.show()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment