【问题标题】:Python matplotlib scatter plot import colormap listPython matplotlib散点图导入颜色图列表
【发布时间】:2020-12-30 12:59:40
【问题描述】:

如何像导入颜色列表一样导入颜色表列表。我想将其用于散点图。 我可以通过

导入一系列颜色
import matplotlib._color_data as mcd

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

同样,我想获取颜色图列表。预期输出:

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

【问题讨论】:

    标签: python matplotlib plot scatter-plot colormap


    【解决方案1】:

    只需从 matplotlib 导入 cm 即可获得颜色图列表

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-15
      • 2014-09-10
      • 2011-08-29
      • 1970-01-01
      • 2015-04-19
      • 2018-07-30
      • 1970-01-01
      相关资源
      最近更新 更多