亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

Python-Seaborn熱圖繪制的實(shí)現(xiàn)方法

系統(tǒng) 2170 0

制圖環(huán)境:
pycharm
python-3.6
Seaborn-0.8

熱圖

            
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
sns.set()
np.random.seed(0)
uniform_data = np.random.rand(10, 12)
ax = sns.heatmap(uniform_data)
plt.show()
          

Python-Seaborn熱圖繪制的實(shí)現(xiàn)方法_第1張圖片

            
# 改變顏色映射的值范圍
ax = sns.heatmap(uniform_data, vmin=0, vmax=1)
plt.show()
          

Python-Seaborn熱圖繪制的實(shí)現(xiàn)方法_第2張圖片

            
uniform_data = np.random.randn(10, 12)
#為以0為中心的數(shù)據(jù)繪制一張熱圖
ax = sns.heatmap(uniform_data, center=0)
plt.show()
          

Python-Seaborn熱圖繪制的實(shí)現(xiàn)方法_第3張圖片

            
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
#用行和列標(biāo)簽繪制
flights_long = sns.load_dataset("flights")
flights = flights_long.pivot("month", "year", "passengers")
# 繪制x-y-z的熱力圖,比如 年-月-銷量 的熱力圖
f, ax = plt.subplots(figsize=(9, 6))
sns.heatmap(flights, ax=ax)
#設(shè)置坐標(biāo)字體方向
label_y = ax.get_yticklabels()
plt.setp(label_y, rotation=360, horizontalalignment='right')
label_x = ax.get_xticklabels()
plt.setp(label_x, rotation=45, horizontalalignment='right')
plt.show()
          

Python-Seaborn熱圖繪制的實(shí)現(xiàn)方法_第4張圖片

            
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
flights_long = sns.load_dataset("flights")
flights = flights_long.pivot("month", "year", "passengers")
# 繪制x-y-z的熱力圖,比如 年-月-銷量 的熱力圖
f, ax = plt.subplots(figsize=(9, 6))
#使用不同的顏色
sns.heatmap(flights, fmt="d",cmap='YlGnBu', ax=ax)
#設(shè)置坐標(biāo)字體方向
label_y = ax.get_yticklabels()
plt.setp(label_y, rotation=360, horizontalalignment='right')
label_x = ax.get_xticklabels()
plt.setp(label_x, rotation=45, horizontalalignment='right')
plt.show()
          

Python-Seaborn熱圖繪制的實(shí)現(xiàn)方法_第5張圖片

注釋熱圖

            
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
flights_long = sns.load_dataset("flights")
flights = flights_long.pivot("month", "year", "passengers")
# 繪制x-y-z的熱力圖,比如 年-月-銷量 的熱力圖
f, ax = plt.subplots(figsize=(9, 6))
#繪制熱力圖,還要將數(shù)值寫到熱力圖上
sns.heatmap(flights, annot=True, fmt="d", ax=ax)
#設(shè)置坐標(biāo)字體方向
label_y = ax.get_yticklabels()
plt.setp(label_y, rotation=360, horizontalalignment='right')
label_x = ax.get_xticklabels()
plt.setp(label_x, rotation=45, horizontalalignment='right')
plt.show()
          

Python-Seaborn熱圖繪制的實(shí)現(xiàn)方法_第6張圖片

            
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
flights_long = sns.load_dataset("flights")
flights = flights_long.pivot("month", "year", "passengers")
# 繪制x-y-z的熱力圖,比如 年-月-銷量 的熱力圖
f, ax = plt.subplots(figsize=(9, 6))
#繪制熱力圖,還要將數(shù)值寫到熱力圖上
#每個(gè)網(wǎng)格上用線隔開
sns.heatmap(flights, annot=True, fmt="d", linewidths=.5, ax=ax)
#設(shè)置坐標(biāo)字體方向
label_y = ax.get_yticklabels()
plt.setp(label_y, rotation=360, horizontalalignment='right')
label_x = ax.get_xticklabels()
plt.setp(label_x, rotation=45, horizontalalignment='right')
plt.show()
          

Python-Seaborn熱圖繪制的實(shí)現(xiàn)方法_第7張圖片

聚類熱圖

            
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
flights_long = sns.load_dataset("flights")
flights = flights_long.pivot("month", "year", "passengers")
# 繪制x-y-z的熱力圖,比如 年-月-銷量 的聚類熱圖
g= sns.clustermap(flights, fmt="d",cmap='YlGnBu')
ax = g.ax_heatmap
label_y = ax.get_yticklabels()
plt.setp(label_y, rotation=360, horizontalalignment='left')
plt.show()
          

Python-Seaborn熱圖繪制的實(shí)現(xiàn)方法_第8張圖片

            
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(color_codes=True)
iris = sns.load_dataset("iris")
species = iris.pop("species")
#設(shè)置圖片大小
g= sns.clustermap(iris, fmt="d",cmap='YlGnBu',figsize=(6,9))
ax = g.ax_heatmap
label_y = ax.get_yticklabels()
plt.setp(label_y, rotation=360, horizontalalignment='left')
#設(shè)置圖片名稱,分辨率,并保存
plt.savefig('cluster.tif',dpi = 300)
plt.show()
          

Python-Seaborn熱圖繪制的實(shí)現(xiàn)方法_第9張圖片

注:更多參數(shù)的用法請(qǐng)查閱官方文檔

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對(duì)您有幫助就好】

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長(zhǎng)會(huì)非常 感謝您的哦!!!

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 亚洲欧美另类日韩 | 色噜噜五月综合激情久久爱 | 中文字幕日韩精品中文区 | 久久er国产精品免费观看1 | 最新四虎4hu影库地址在线 | 国产福利一区二区在线观看 | 特级女人十八毛片a级 | 久久精品亚洲欧美va | 97精品视频在线观看 | 九九啪 | 看全大色黄大色黄大片一级爽 | 激情综合婷婷亚洲图片 | 亚洲va久久久噜噜噜久久男同 | 天天夜夜骑 | 一级韩国aa毛片免费观看 | 欧美视频www | 亚洲国产最新 | 最新国产午夜精品视频不卡 | 美女久久久久久 | 老子午夜伦不卡影院 | 变态 调教 视频 国产九色 | 中文字幕亚洲在线 | 国产视频中文字幕 | 离线枕边人在线观看 | 草的爽免费视频 | 午夜影视在线观看 | 久草观看视频 | 日韩中文一区 | 久久精品全国免费观看国产 | 久久久久久久久综合影视网 | 九色福利视频 | 欧美三级做爰视频 | 免费看国产精品麻豆 | 国产午夜精品不卡观看 | 性做久久久久久久免费看 | 一级毛片成人午夜 | 亚洲欧美网| 狠狠噜噜 | 精品一区二区视频在线观看 | 99精品热线在线观看免费视频 | 国产精品美女免费视频大全 |