Generate a colorbar that is a portion of HSV map

Jimmy Ye
Feb 4, 2022

--

The HSV mapping is as below:

If we want to use only a portion of this map, say from green to blue, we can use the following code.

# modified hsv in 256 color class
hsv_modified = cm.get_cmap(‘hsv’, 256)# create new hsv colormaps in range of 0.3 (green) to 0.7 (blue)
newcmp = ListedColormap(hsv_modified(np.linspace(0.3, 0.7, 256)))# show figure
plt.figure(figsize=(7, 6))
plt.pcolormesh(data, cmap = newcmp)
plt.colorbar()

--

--

No responses yet