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. DataTable怎么判断一列是否为主键?

    在普通情况下,我们使用SqlDataAdapter来Fill填充DataTable,如果使用下列代码我们是不能拿到主键列的: dataadapter.Fill(Table); DataColumn[] ...

  2. Jump Game leetcode java

    题目: Given an array of non-negative integers, you are initially positioned at the first index of the ...

  3. Memcached和Memcache 配置教程windows X64

    一.Memcached和Memcache的区别: 网上关于Memcached和Memcache的区别的理解众说纷纭,我个人的理解是: Memcached是一个内存缓存系统,而Memcache是php的 ...

  4. C语言:strcpy()和memcpy()

    一.strcpy和memcpy都是标准C库函数,它们有下面的特点:      1.strcpy提供了字符串的复制.即strcpy只用于字符串复制,并且它不仅复制字符串内容之外,还会复制字符串的结束符. ...

  5. C#中判断为空

    在判断ComBox是否有选择条目(Item)时,判断出错,原因在于SeletedItem.ToString()存在问题,根本就不能转为String,去掉即可. null 关键字是表示不引用任何对象的空 ...

  6. GIS专业书籍、文档、数据、网站、工具等干货

    整理.分享一些个人整理的GIS专业书籍.文档.数据.网站.工具等.也希望大家将自己的心得也分享出来,一起交流,共同进步. 如果下载链接失效,请到这里去:地信网 一.原理应用类 GIS基础类 01.地理 ...

  7. access2003的使用

    access2003中如何用sql语句创建表 http://zhidao.baidu.com/link?url=dinVbwoI20Xz__NbcIeBPdkjeXRWmZNB0xJvdr0eMBqN ...

  8. OC 创建单例

    static BlockBackground *_sharedInstance = nil; + (BlockBackground*)sharedInstance { if (_sharedInsta ...

  9. HTTP Content-type整理

    文件扩展名 Content-Type(Mime-Type) 文件扩展名 Content-Type(Mime-Type) .*( 二进制流.不知道下载文件类型) application/octet-st ...

  10. 在VC中创建DLL文件的方法步骤

    一.Win32动态链接库 1.制作的步骤: (1)新建WIN32 Dynamic-link Library工程,工程名为MyDll,选择A simple DLL project类型. (2)MyDll ...