python matplotlib包图像配色方案
Posted Donser
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python matplotlib包图像配色方案相关的知识,希望对你有一定的参考价值。
可选的配色方案:
Accent, Accent_r, Blues, Blues_r, BrBG, BrBG_r, BuGn, BuGn_r, BuPu, BuPu_r, CMRmap, CMRmap_r, Dark2, Dark2_r, GnBu, GnBu_r, 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_heat, gist_heat_r, gist_ncar, gist_ncar_r, gist_rainbow, gist_rainbow_r, gist_stern, gist_stern_r, gist_yarg, gist_yarg_r, gnuplot, gnuplot2, gnuplot2_r, gnuplot_r, gray, gray_r, 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, viridis, viridis_r, winter, winter_r
RGB对照表:https://www.114la.com/other/rgb.htm
常用的几个:
示例代码:
cm=\'Spectral\' #hot bone cool copper gray hsv inferno jet magma pink plasma summer viridis bwr ocean rainbow coolwarm Spectral......................
norm = matplotlib.colors.Normalize(vmin=min, vmax=max)
map=plt.imshow(plt_arr,interpolation=\'nearest\',cmap=cm,norm=norm, origin=\'upper\') # plt_arr是要显示的数据
mydpi=1000
plt.savefig("filename.png", dpi=mydpi ,bbox_inches=\'tight\', pad_inches=0) # ,bbox_inches=\'tight\' less white area
plt.show()
图像实例:
hsv
hot
cool
rainbow
gist_earth
以上是关于python matplotlib包图像配色方案的主要内容,如果未能解决你的问题,请参考以下文章
CMasher极大丰富Matplotlib自带colormaps
CMasher极大丰富Matplotlib自带colormaps
Python使用matplotlib保存图像时发生自动裁剪丢了部分标签信息解决方案(plt.savefig保存时丢失了部分标签字符)