怎么样上传网站资料,三亚网站建设方案,前端和ui学哪个更好,企业管理模块Matplotlib 提供了许多内置的颜色映射#xff08;colormap#xff09;选项#xff0c;可以将数值数据映射到色彩范围——热力图、温度图、地图等可视化经常会用到。
# colormap 有两种引用形式plt.imshow(data, cmapBlues)plt.imshow(data, cmapcm.Blues)
颜色映射可以分为…Matplotlib 提供了许多内置的颜色映射colormap选项可以将数值数据映射到色彩范围——热力图、温度图、地图等可视化经常会用到。
# colormap 有两种引用形式plt.imshow(data, cmapBlues)plt.imshow(data, cmapcm.Blues)
颜色映射可以分为连续的Continuous和离散的Discrete两大类。
前者适用于连续数据颜色映射是渐变的如Blues后者适用于离散数据颜色映射是一段一段的如Paired。
每种颜色映射都有正反两个映射方向比如 Blues 和 Blues_r。 Matplotlib 内置了170中颜色映射全部在下图中列出了可以根据自己的可视化需求选择合适的颜色映射。 感兴趣的话也可以用下面的代码把每一种颜色映射生成一张示例图。
# -*- coding: utf-8 -*-author: WeissSun
import numpy as np
import matplotlib.pyplot as plt# 创建随机数据
data np.random.rand(10, 10)color_map_list [
Accent, Accent_r, Blues, Blues_r, BrBG, BrBG_r,
BuGn, BuGn_r, BuPu, BuPu_r, CMRmap, CMRmap_r,
Dark2, Dark2_r, GnBu, GnBu_r, Grays, Greens, Greens_r,
Greys, Greys_r, OrRd, OrRd_r, Oranges, Oranges_r,
PRGn, PRGn_r, Paired, Paired_r, Pastel1, Pastel1_r,
Pastel2, Pastel2_r, PiYG, PiYG_r, PuBu, PuBuGn, PuBuGn_r, PuBu_r,
PuOr, PuOr_r, PuRd, PuRd_r, Purples, Purples_r, RdBu, RdBu_r,
RdGy, RdGy_r, RdPu, RdPu_r, RdYlBu, RdYlBu_r, RdYlGn, RdYlGn_r,
Reds, Reds_r, Set1, Set1_r, Set2, Set2_r, Set3, Set3_r,
Spectral, Spectral_r, Wistia, Wistia_r, YlGn, YlGnBu, YlGnBu_r, YlGn_r,
YlOrBr, YlOrBr_r, YlOrRd, YlOrRd_r, afmhot, afmhot_r, autumn, autumn_r,
binary, binary_r, bone, bone_r, brg, brg_r, bwr, bwr_r, cividis,
cividis_r, cool, cool_r, coolwarm, coolwarm_r, copper, copper_r,
cubehelix, cubehelix_r, flag, flag_r, gist_earth, gist_earth_r,
gist_gray, gist_gray_r, gist_grey, gist_heat, gist_heat_r, gist_ncar,gist_ncar_r, gist_rainbow, gist_rainbow_r, gist_stern, gist_stern_r,
gist_yarg, gist_yarg_r, gist_yerg, gnuplot, gnuplot2, gnuplot2_r,
gnuplot_r, gray, gray_r, grey, hot, hot_r, hsv, hsv_r, inferno,inferno_r, jet, jet_r, magma, magma_r, nipy_spectral, nipy_spectral_r,
ocean, ocean_r, pink, pink_r, plasma, plasma_r, prism, prism_r,
rainbow, rainbow_r, seismic, seismic_r, spring, spring_r, summer,
summer_r, tab10, tab10_r, tab20, tab20_r, tab20b, tab20b_r, tab20c,
tab20c_r, terrain, terrain_r, turbo, turbo_r, twilight, twilight_r,
twilight_shifted, twilight_shifted_r, viridis, viridis_r, winter, winter_r
]for color_map in color_map_list:plt.imshow(data, cmapcolor_map)plt.colorbar()plt.title(color_map)# plt.show()plt.savefig(f{color_map}.png)plt.close()