国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

Python matplotlib畫圖實(shí)例之繪制擁有彩條的圖表

2020-02-16 11:22:23
字體:
供稿:網(wǎng)友

生產(chǎn)定制一個(gè)彩條標(biāo)簽。

首先導(dǎo)入:

import matplotlib.pyplot as pltimport numpy as npfrom matplotlib import cmfrom numpy.random import randn

制作擁有垂直(默認(rèn))彩條的圖表:

fig, ax = plt.subplots()data = np.clip(randn(250, 250), -1, 1)cax = ax.imshow(data, interpolation='nearest', cmap=cm.coolwarm)ax.set_title('Gaussian noise with vertical colorbar')# Add colorbar, make sure to specify tick locations to match desired ticklabelscbar = fig.colorbar(cax, ticks=[-1, 0, 1])cbar.ax.set_yticklabels(['< -1', '0', '> 1']) # vertically oriented colorbar

效果圖:

制作擁有水平彩條的圖表:

fig, ax = plt.subplots()data = np.clip(randn(250, 250), -1, 1)cax = ax.imshow(data, interpolation='nearest', cmap=cm.afmhot)ax.set_title('Gaussian noise with horizontal colorbar')cbar = fig.colorbar(cax, ticks=[-1, 0, 1], orientation='horizontal')cbar.ax.set_xticklabels(['Low', 'Medium', 'High']) # horizontal colorbarplt.show()

效果圖:

腳本運(yùn)行耗時(shí):(0分0.075秒)

總結(jié)

以上就是本文關(guān)于Python matplotlib畫圖實(shí)例之繪制擁有彩條的圖表的全部?jī)?nèi)容,希望對(duì)大家有所幫助。感興趣的朋友可以繼續(xù)參閱本站其他相關(guān)專題,如有不足之處,歡迎留言指出。感謝朋友們對(duì)本站的支持!

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 荥经县| 西峡县| 美姑县| 六盘水市| 宜黄县| 平乡县| 井研县| 同仁县| 福安市| 山东省| 扶风县| 汪清县| 东平县| 青田县| 绥宁县| 云南省| 苏州市| 潞城市| 永平县| 南陵县| 合川市| 鹤壁市| 视频| 登封市| 额尔古纳市| 普格县| 南木林县| 孟州市| 泸水县| 张掖市| 安远县| 历史| 贵溪市| 淮安市| 台东县| 潍坊市| 二连浩特市| 德令哈市| 华池县| 信丰县| 上杭县|