小白教程

 找回密码
 立即注册
查看: 7217|回复: 1

关于matplotlib库引用的问题

[复制链接]

1

主题

1

帖子

3

积分

新手上路

Rank: 1

积分
3
发表于 2021-5-7 09:32:27 | 显示全部楼层 |阅读模式
最近,在学习Matplotlib的基础知识时,我遇到了函数调用的问题。以下
  1. x_values = list(range(1, 1001))
  2. y_values = [x ** 2 for x in x_values]

  3. plt.scatter(x_values, y_values, c=y_values, cmap=plt.cm.Blues, edgecolor='none', s=40)
复制代码

想测试一个渐变色域,其中 cmap 参数 取 plt.cm.Blues
问题是,打开了cm.py模块的源码,没有找到任何关于色域取值的解释,即 cm中没有任何属性可以取 Blues。
后来又尝试打开了 _cm.py模块,里边有datad字典:
  1. datad = {
  2.     'Blues': _Blues_data,
  3.     'BrBG': _BrBG_data,
  4.     'BuGn': _BuGn_data,
  5.     'BuPu': _BuPu_data,
  6.     'CMRmap': _CMRmap_data,
  7.     'GnBu': _GnBu_data,
  8.     'Greens': _Greens_data,
  9.     'Greys': _Greys_data,
  10.     'OrRd': _OrRd_data,
  11.     'Oranges': _Oranges_data,
  12.     'PRGn': _PRGn_data,
  13.     'PiYG': _PiYG_data,
  14.     'PuBu': _PuBu_data,
  15.     'PuBuGn': _PuBuGn_data,
  16.     'PuOr': _PuOr_data,
  17.     'PuRd': _PuRd_data,
  18.     'Purples': _Purples_data,
  19.     'RdBu': _RdBu_data,
  20.     'RdGy': _RdGy_data,
  21.     'RdPu': _RdPu_data,
  22.     'RdYlBu': _RdYlBu_data,
  23.     'RdYlGn': _RdYlGn_data,
  24.     'Reds': _Reds_data,
  25.     'Spectral': _Spectral_data,
  26.     'Wistia': _wistia_data,
  27.     'YlGn': _YlGn_data,
  28.     'YlGnBu': _YlGnBu_data,
  29.     'YlOrBr': _YlOrBr_data,
  30.     'YlOrRd': _YlOrRd_data,
  31.     'afmhot': _afmhot_data,
  32.     'autumn': _autumn_data,
  33.     'binary': _binary_data,
  34.     'bone': _bone_data,
  35.     'brg': _brg_data,
  36.     'bwr': _bwr_data,
  37.     'cool': _cool_data,
  38.     'coolwarm': _coolwarm_data,
  39.     'copper': _copper_data,
  40.     'cubehelix': _cubehelix_data,
  41.     'flag': _flag_data,
  42.     'gist_earth': _gist_earth_data,
  43.     'gist_gray': _gist_gray_data,
  44.     'gist_heat': _gist_heat_data,
  45.     'gist_ncar': _gist_ncar_data,
  46.     'gist_rainbow': _gist_rainbow_data,
  47.     'gist_stern': _gist_stern_data,
  48.     'gist_yarg': _gist_yarg_data,
  49.     'gnuplot': _gnuplot_data,
  50.     'gnuplot2': _gnuplot2_data,
  51.     'gray': _gray_data,
  52.     'hot': _hot_data,
  53.     'hsv': _hsv_data,
  54.     'jet': _jet_data,
  55.     'nipy_spectral': _nipy_spectral_data,
  56.     'ocean': _ocean_data,
  57.     'pink': _pink_data,
  58.     'prism': _prism_data,
  59.     'rainbow': _rainbow_data,
  60.     'seismic': _seismic_data,
  61.     'spring': _spring_data,
  62.     'summer': _summer_data,
  63.     'terrain': _terrain_data,
  64.     'winter': _winter_data,
  65.     # Qualitative
  66.     'Accent': {'listed': _Accent_data},
  67.     'Dark2': {'listed': _Dark2_data},
  68.     'Paired': {'listed': _Paired_data},
  69.     'Pastel1': {'listed': _Pastel1_data},
  70.     'Pastel2': {'listed': _Pastel2_data},
  71.     'Set1': {'listed': _Set1_data},
  72.     'Set2': {'listed': _Set2_data},
  73.     'Set3': {'listed': _Set3_data},
  74.     'tab10': {'listed': _tab10_data},
  75.     'tab20': {'listed': _tab20_data},
  76.     'tab20b': {'listed': _tab20b_data},
  77.     'tab20c': {'listed': _tab20c_data},
  78. }
复制代码





回复

使用道具 举报

0

主题

1

帖子

2

积分

新手上路

Rank: 1

积分
2
发表于 2021-5-26 20:13:59 | 显示全部楼层
楼主知道了吗,最近也在愁这个问题
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|小白教程 ( 粤ICP备20019910号 )

GMT+8, 2024-9-20 14:31 , Processed in 0.031146 second(s), 24 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc. Template By 【未来科技】【 www.wekei.cn 】

快速回复 返回顶部 返回列表