3

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..]

1 Answer 1

1

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']
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.