python热图_Python绘制热图
1.matplitlib绘制热图
import random
from matplotlib import pyplot as plt
from matplotlib import cm
from matplotlib import axes
def draw():
# define the x and y axis of the hotmap
xLabel = ['A', 'B', 'C', 'D', 'E']
yLabel = ['1', '2', '3', '4', '5']
# prepaer the data, generate the two-dimension data
data = []
for i in range(5):
temp = []
for j in range(5):
k = random.randint(0,100)
temp.append(k)
data.append(temp)
# plot the figure
fig = plt.figure()
ax = fig.add_subplot(111)
# define the scale
ax.set_yticks(range(len(yLabel)))
ax.set_yticklabels(yLabel, fontproperties=plt.cm.hot_r)
ax.set_xticks(range(len(xLabel)))
ax.set_xtickslabels(xLabel)
# make the figure and select the style of hotmap
im = ax.imshow(data, cmap = plt.cm.hot_r) # the value is more high, the color is more deep
# im = ax.imshow(data, cmap = plt.cm.hot) # the value is more high, the color is more shallow
# plt.cm.~ hot, cool, gray, bone, white, spring, summer, autumn, winter
# add the scale bar of the right site
plt.colorbar(im)
plt.title("This is a title")
plt.show()
d = draw()
2.Seaborn绘制热图
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
sns.set()
# data 1
np.random.seed(0)
uniform_data = np.random.rand(10, 12, vmin = 0, vmax = 1, center = 0)
# vmin=0, vmax=1 : the scope of colorbar value
# center=0 : colorbar valuee centered at 0
ax = sns.heatmap(uniform_data)
# data 2
flights_long = sns.load_dataset("flights")
flights = flights_long.pivot("month", "year", "passengers")
f, ax = plt.subplots(figsize = (9, 6))
# annot = True: show the value
sns.heatmap(flights, annot = True, fmt = 'd', cmap = 'Y|GnBu', linewidth = 5, ax = ax)
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()
# https://www.jianshu.com/p/d105d934d876
python热图_Python绘制热图相关推荐
- python热图_Python 绘制热图
原博文 2019-09-03 16:50 − 1.matplitlib绘制热图 1 import random 2 from matplotlib import pyplot as plt 3 fro ...
- python 日历热力图_Python绘制日历图和热力图
本文以2019年全国各城市的空气质量观测数据为例,利用matplotlib.calmap.pyecharts绘制日历图和热力图.在绘图之前先利用pandas对空气质量数据进行处理. 2019年全国各城 ...
- python日历图_Python绘制日历图和热力图
本文以2019年全国各城市的空气质量观测数据为例,利用matplotlib.calmap.pyecharts绘制日历图和热力图.在绘图之前先利用pandas对空气质量数据进行处理. 2019年全国各城 ...
- 利用python绘制雪景图_python绘制雪景图
本文实例为大家分享了python绘制雪景图的具体代码,供大家参考,具体内容如下 绘制雪景图,应用到turtle和random. from turtle import * from random imp ...
- python彩虹图_python绘制彩虹图
本文实例为大家分享了python绘制彩虹图的具体代码,供大家参考,具体内容如下 from turtle import * #控制彩虹路径 def path(pen, r, g, b): pen.pen ...
- python分析数据走势图_python绘制趋势图的示例
import matplotlib.pyplot as plt #plt用于显示图片 import matplotlib.image as mping #mping用于读取图片 import date ...
- python画漏斗图_python绘制漏斗图步骤详解
pyecharts中的Funnel函数可以绘制漏斗图,自动根据数据大小生成由大到小自上而下排列的一个漏斗样的图形. 1.导入Funnel模块. from pyecharts import Funnel ...
- python彩虹代码_python绘制彩虹图
本文实例为大家分享了python绘制彩虹图的具体代码,供大家参考,具体内容如下 from turtle import * #控制彩虹路径 def path(pen, r, g, b): pen.pen ...
- python生成热度图_Python 绘制热度图(seaborn)
原博文 2020-05-08 15:16 − 进行数据处理时,对于数据的可视化展示可以更好的表现数据的关系 论文中,漂亮的热度图会让人眼前一亮 Seaborn 中的 heatmap就可以用来创建热度图 ...
最新文章
- LIVE555中RTSP客户端接收媒体流分析及测试代码
- Python天天练2--面向对象+异常
- 解决 WIn7 启动时“你有等待写入光盘的文件”
- 点击费用百度竞价修改方法
- redhat6.5 yum register 问题
- Hbase总结(十)Hhase性能调优
- springCloud - 第3篇 - 消费者调用服务 ( RestTemplate + Ribbon )
- rcmd–App Switcher for Mac快速切换应用程序
- 智能优化算法应用:基于GWO优化的灰度熵图像多阈值分割 - 附代码
- h5网页小游戏php源码,H5 组词小游戏源代码
- 如何在软件里显示编译时间?__DATE__和__TIME__
- FPGA图像处理 —— fpga实现cameralink接口图像传输
- ipa在线安装搭建_在线安装IPA 文件和视频下载
- 一行代码实现F11的功能,即让浏览器窗口全屏
- VUE系列——弹窗代码编写与调用弹窗过程详解
- Macmini 2018安装 ArchLinux
- 苹果开发者注册了邓白氏编码不能用,查询时提示该组织不存在怎么办?
- 排列组合“捆绑法”、“插空法”、“插板法
- 计算机如何访问苹果6s的相册,苹果手机怎么连接到电脑传照片 两种方法帮你实现!...
- 解决 XXX cannot be resolved or is not a field 问题