Skip to content
Snippets Groups Projects

Viz add colorbar

Merged s214743 requested to merge viz-add-colorbar into main
1 file
+ 7
1
Compare changes
  • Side-by-side
  • Inline
+ 7
1
@@ -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()
Loading