最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時(shí)間:2019年07月15日 09:45:17   作者:sunchengquan  
這篇文章主要介紹了Python-Seaborn熱圖繪制的實(shí)現(xiàn)方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧

制圖環(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()

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

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

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的熱力圖,比如 年-月-銷(xiāo)量 的熱力圖
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()

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的熱力圖,比如 年-月-銷(xiāo)量 的熱力圖
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()

注釋熱圖

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的熱力圖,比如 年-月-銷(xiāo)量 的熱力圖
f, ax = plt.subplots(figsize=(9, 6))
#繪制熱力圖,還要將數(shù)值寫(xiě)到熱力圖上
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()

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的熱力圖,比如 年-月-銷(xiāo)量 的熱力圖
f, ax = plt.subplots(figsize=(9, 6))
#繪制熱力圖,還要將數(shù)值寫(xiě)到熱力圖上
#每個(gè)網(wǎng)格上用線隔開(kāi)
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()

聚類熱圖

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的熱力圖,比如 年-月-銷(xiāo)量 的聚類熱圖
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()

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()

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

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

相關(guān)文章

最新評(píng)論

通城县| 济源市| 扶沟县| 威远县| 华坪县| 沙河市| 富民县| 饶阳县| 高青县| 四会市| 揭阳市| 长顺县| 新民市| 永吉县| 嘉兴市| 镶黄旗| 四子王旗| 全椒县| 嵩明县| 建瓯市| 凤台县| 东城区| 凤凰县| 河津市| 孟村| 永福县| 萝北县| 崇礼县| 福贡县| 池州市| 黔南| 邵阳县| 西乌珠穆沁旗| 穆棱市| 静乐县| 会理县| 昭通市| 定陶县| 噶尔县| 四会市| 冕宁县|