Mainland
Mainland

Reputation: 4564

Python matplotlib scatter plot import colormap list

How do I import colormap list just as I do import colors list. This I want to use for scatter plots. I can import a range of colors by

import matplotlib._color_data as mcd

colorslist = list(mcd.XKCD_COLORS.values())[::3]
print(colorlist)
 ['#d1b26f',
 '#06c2ac',
 '#bf77f6',
 '#75bbfd',
 '#96f97b',
 '#95d0fc',
 '#ff81c0',
 '#7e1e9c']

Similarly I want to obtain list of colormaps. Expected output:

colormaplist = [a list of available colormap colors]
print(colormaplist)
[Accent, Accent_r, Blues, Blues_r, BrBG, BrBG_r, BuGn, BuGn_r, BuPu, BuPu_r, CMRmap, CMRmap_r..]

Upvotes: 3

Views: 354

Answers (1)

Miguel Trejo
Miguel Trejo

Reputation: 6667

Just import cm from matplotlib and you can get a list of colormaps

from matplotlib import cm
dir(cm)
>>> ['Accent',
 'Accent_r',
 'Blues',
 'Blues_r',
 'BrBG',
 'BrBG_r',
 'BuGn',
 'BuGn_r',
 'BuPu',
 'BuPu_r',
 'CMRmap',
 'CMRmap_r',
....,
'viridis_r',
 'winter',
 'winter_r']

Upvotes: 1

Related Questions