Created
July 25, 2020 02:39
-
-
Save KerryHalupka/0912632421b621f1133acf38adc3fce8 to your computer and use it in GitHub Desktop.
Test out different matplotlib colormaps
This file contains 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 | |
fig, axes = plt.subplots(2,2, figsize=(10,10)) | |
# the colormaps we'll be trying out | |
cmap_list = ['RdPu', 'spring', 'PRGn', 'gnuplot'] | |
for ax, name in zip(axes.flatten(), cmap_list): | |
im = ax.imshow(z, aspect='auto', cmap=plt.get_cmap(name)) | |
ax.yaxis.set_major_locator(plt.NullLocator()) # remove y axis ticks | |
ax.xaxis.set_major_locator(plt.NullLocator()) # remove x axis ticks | |
ax.set_aspect('equal', adjustable='box') # make subplots square | |
ax.set_title(f'Cmap: {name}', fontsize=18) # add a title to each | |
divider = make_axes_locatable(ax) # make colorbar same size as each subplot | |
cax = divider.append_axes("right", size="5%", pad=0.1) | |
plt.colorbar(im, cax=cax) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment