1.基础知识点回顾

  • 1.plot(x, y, marker='D')表示绘制折线图,marker设置样式菱形。
  • 2.scatter(x, y, marker='s', color='r')绘制散点图,红色正方形。
  • 3.bar(x, y, 0.5, color='c')绘制柱状图,间距为0.5,原色。
  • 4.hist(data,40,normed=1,histtype='bar',facecolor='yellowgreen',alpha=0.75)直方图。
  • 5.设置x轴和y轴的坐标值:
    • xlim(-2.5, 2.5) #设置x轴范围
    • ylim(-1, 1) #设置y轴范围
  • 6.显示中文和负号代码如下:
    • plt.rcParams['font.sas-serig']=['SimHei'] #用来正常显示中文标签
    • plt.rcParams['axes.unicode_minus']=False #用来正常显示负号

2.Heatmap热图基础知识

详情请参阅:http://matplotlib.org/users/image_tutorial.html

In [1]: import matplot.pyplot as plt
In [2]: help(plt.imshow)
Help on function imshow in module matplotlib.pyplot: imshow(X, cmap=None, norm=None, aspect=None, interpolation=None, alpha=None, vmin=None, vmax=None, origin=None, extent=None, shape=None, filternorm=1, filterrad=4.0, imlim=None, resample=None, url=None, hold=None, data=None, **kwargs)
Display an image on the axes. Parameters
----------
X : array_like, shape (n, m) or (n, m, 3) or (n, m, 4)
Display the image in `X` to current axes. `X` may be an
array or a PIL image. If `X` is an array, it
can have the following shapes and types: - MxN -- values to be mapped (float or int)
- MxNx3 -- RGB (float or uint8)
- MxNx4 -- RGBA (float or uint8) The value for each component of MxNx3 and MxNx4 float arrays
should be in the range 0.0 to 1.0. MxN arrays are mapped
to colors based on the `norm` (mapping scalar to scalar)
and the `cmap` (mapping the normed scalar to a color). cmap : `~matplotlib.colors.Colormap`, optional, default: None
If None, default to rc `image.cmap` value. `cmap` is ignored
if `X` is 3-D, directly specifying RGB(A) values.
参数X可以是图片也可以数组,若是数组,必须以下三种形式

3.Heatmap热图绘制

import numpy as np
from matplotlib import pyplot as plt
from matplotlib import cm
from matplotlib import axes def draw_heatmap(data,xlabels,ylabels):
#cmap=cm.Blues
cmap=cm.get_cmap('rainbow',1000)
figure=plt.figure(facecolor='w')
ax=figure.add_subplot(1,1,1,position=[0.1,0.15,0.8,0.8])
ax.set_yticks(range(len(ylabels)))
ax.set_yticklabels(ylabels)
ax.set_xticks(range(len(xlabels)))
ax.set_xticklabels(xlabels)
map=ax.imshow(data,interpolation='nearest',cmap=cmap,aspect='auto',vmin=a.min(),vmax=a.max())
cb=plt.colorbar(mappable=map,cax=None,ax=None,shrink=0.5)
plt.show() a=np.random.rand(10,10)
print(a)
xlabels=['A','B','C','D','E','F','G','H','I','J']
ylabels=['a','b','c','d','e','f','g','h','i','j']
draw_heatmap(a,xlabels,ylabels)

这里想把某块显示成一种颜色,则需要调用interpolation='nearest'参数即可

matplotlib热图的更多相关文章

  1. 基于matplotlib的数据可视化 - 热图imshow

    热图: Display an image on the axes. 可以用来比较两个矩阵的相似程度 mp.imshow(z, cmap=颜色映射,origin=垂直轴向) imshow( X, cma ...

  2. Matplotlib学习---用matplotlib画热图(heatmap)

    这里利用Nathan Yau所著的<鲜活的数据:数据可视化指南>一书中的数据,学习画图. 数据地址:http://datasets.flowingdata.com/ppg2008.csv ...

  3. python matplotlib imshow热图坐标替换/映射

    今天遇到了这样一个问题,使用matplotlib绘制热图数组中横纵坐标自然是图片的像素排列顺序, 但是这样带来的问题就是画出来的x,y轴中坐标点的数据任然是x,y在数组中的下标, 实际中我们可能期望坐 ...

  4. Python图表数据可视化Seaborn:3. 线性关系数据| 时间线图表| 热图

    1. 线性关系数据可视化 lmplot( ) import numpy as np import pandas as pd import matplotlib.pyplot as plt import ...

  5. 基于HTML5实现3D热图Heatmap应用

    Heatmap热图通过众多数据点信息,汇聚成直观可视化颜色效果,热图已广泛被应用于气象预报.医疗成像.机房温度监控等行业,甚至应用于竞技体育领域的数据分析. http://www.hightopo.c ...

  6. 用Excel制作热图(heatmap)的方法

    http://jingyan.baidu.com/article/64d05a0240ec75de55f73bd8.html 利用Excel 2010及以上版本的"条件格式"--& ...

  7. Heatmap.js v2.0 – 最强大的 Web 动态热图

    Heatmap 是用来呈现一定区域内的统计度量,最常见的网站访问热力图就是以特殊高亮的形式显示访客热衷的页面区域和访客所在的地理区域的图示.Heatmap.js 这个 JavaScript 库可以实现 ...

  8. 基于HTML5实现的Heatmap热图3D应用

    Heatmap热图通过众多数据点信息,汇聚成直观可视化颜色效果,热图已广泛被应用于气象预报.医疗成像.机房温度监控等行业,甚至应用于竞技体育领域的数据分析. 已有众多文章分享了生成Heatmap热图原 ...

  9. matplotlib 出图示例

    如果你想要在Linxu中获得一个高效.自动化.高质量的科学画图的解决方案,应该考虑尝试下matplotlib库.Matplotlib是基于python的开源科学测绘包,基于python软件基金会许可证 ...

随机推荐

  1. 如何查看ETW Trace?

    三种方法: LogParser Tractrpt - C:\Windows\System32 SvcTraceViewer.exe   后面的链接中有使用的详细步骤.   参考资料 ========= ...

  2. POJ 1265:Area

    Area Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4725   Accepted: 2135 Description ...

  3. 微信小程序开发:设置消息推送

    开发设置中,启用并设置消息推送配置后,用户发给小程序的消息以及开发者需要的事件推送,都将被微信转发至该服务器地址中. 不过照着说明去操作,即使按照最简单的明文方式去设置,还是提示Token验证失败.仔 ...

  4. STL与多线程+写时拷贝

    http://blog.csdn.net/liuxuejiang158blog/article/details/13251379 STL并不是线程安全的,当多个线程同时读取STL时没什么问题.当多个线 ...

  5. Linux下启动eclipse报错

    A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be avail   Java RunTime Environm ...

  6. Oracle体系结构二(学习笔记)

  7. Linux 驱动之内核定时器

    1.定时器 之前说过两类跟时间相关的内核结构. 1.延时:通过忙等待或者睡眠机制实现延时. 2.tasklet和工作队列,通过某种机制使工作推后运行,但不知道运行的详细时间. 接下来要介绍的定时器,可 ...

  8. 强制MySQL查询走索引和强制查询不缓存

    有些情况下,表中创建了索引但是EXPLAIN的查看执行计划的时候发现并没有走索引.是因为优化器认为该语句不使用索引效率更好. 当然也可以强制走索引.类似: SELECT uid,uname FROM ...

  9. vue 通信方式汇总

    1.10种通信方式 10种:https://juejin.im/post/5bd18c72e51d455e3f6e4334 2.除此之外,还有children和ref. 需要注意 $children  ...

  10. iOS 事件传递及响应过程

    iOS 事件传递及响应过程 -->>事件到来-->>事件分发 -->>事件响应 事件( Events) 官方文档( Events(iOS)) 是这样描写叙述的: U ...