Skip to content

Instantly share code, notes, and snippets.

@KerryHalupka
Last active August 27, 2020 09:21
Show Gist options
  • Save KerryHalupka/67a6775529e0811a318ffc7a1362c777 to your computer and use it in GitHub Desktop.
Save KerryHalupka/67a6775529e0811a318ffc7a1362c777 to your computer and use it in GitHub Desktop.
x, y = np.mgrid[-5:5:0.05, -5:5:0.05]
z = (np.sqrt(x**2 + y**2) + np.sin(x**2 + y**2))
z = 7*(z/z.max())-2 #shift range to between -2 and 5
center = 0
divnorm = mcolors.TwoSlopeNorm(vmin=z.min(),vcenter=center, vmax=z.max())
fig, ax = plt.subplots(1,1)
hex_list = ['#0091ad', '#d6f6eb', '#fdf1d2', '#faaaae', '#ff57bb']
im = ax.imshow(z, cmap=get_continuous_cmap(hex_list), norm=divnorm)
fig.colorbar(im)
ax.yaxis.set_major_locator(plt.NullLocator()) # remove y axis ticks
ax.xaxis.set_major_locator(plt.NullLocator()) # remove x axis ticks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment