首页 > 编程知识 正文

matplotlib中文教程,matplotlib安装失败

时间:2023-05-03 11:09:36 阅读:41043 作者:1694

PLT.scatter (x [ :0 ],x [ :1 ],c=data_index,alpha=0.6,CMAP=PLT.cm.get_cmap ) ' set1 '

matplotlib用于创建热图的颜色映射有很多种,您可以选择不同的颜色映射来创建所需的热图。 源代码如下:

该代码是根据官方网站(http://matplotlib.org/examples/color/color maps _ reference.html )的源代码转载的

importnumpyasnpimportmatplotlib.pyplotasplt # havecolormapsseparatedintocategories 3360 # http://matplotlib.org/examples/examples color maps _ reference.htmlc maps=[ ' perceptuallyuniformsequential ',['viridis ',' inferno ',' plasma,] ' Oranges '、' OrRd '、' PuBu '、' PuBuGn '、' PuRd '、' Purples '、' rdples '、' rdples' (sequential(2)、) ) [ ] ['BrBG '、' bwr '、' coolwarm '、' PiYG '、' PRGn '、' PuOr '、' RdBu '、' RdGy '、' RdYlBu '、' RdYlGn '、' SPECT (Miscellaneous '、['gist_earth '、' teerth] 'cubehelix '、' gnuplot '、' gnuplot2'、' gist_ncar '、' nipy _ ) ' gist _ rainbridge ' prism ' (nrows=max (len (cmap _ list ) for cmap_category,cmap_list in cmaps ) gradient=nt ) gradient () def plot _ color _ gradients (cmap _ category,cmap_list ) : fig,axes=PLT.subplots ) nrows=nrows right=0.99 ) axes [0].set _ title (cmap _ category ' color maps ',fontsize=14 ) for ax,nameinzip(ameinzip ) ) APS y_text,name,va='center ',ha='right ',fontsize=10 ) # Turn off *all* ticks spines, notjusttheoneswithcolormaps.foraxinaxes : ax.set _ axis _ off (for cmap _ category,cmap _ listincmaps : plot _ off

其效果图如下。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。