Last active
December 3, 2019 14:34
-
-
Save thomasaarholt/56d96909f6d823a98c10162c7c3522a9 to your computer and use it in GitHub Desktop.
Add colorbar next to image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mpl_toolkits.axes_grid1 import make_axes_locatable | |
def colorbar(mappable): | |
"mappable is img = plt.imshow()" | |
ax = mappable.axes | |
fig = ax.figure | |
divider = make_axes_locatable(ax) | |
cax = divider.append_axes("right", size="5%", pad=0.05) | |
cax.aname = 'colorbar' | |
return fig.colorbar(mappable, cax=cax) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment