python 热图画法_在python中绘制热图

这篇博客介绍如何在Python中使用matplotlib库绘制2D热力图。通过将坐标x、y和对应的"热量"值z结合,创建了一张渐变色的热力图。代码示例展示了如何设置等高线级别、颜色映射和调整颜色条的显示选项,以生成具有清晰标签的可视化结果。
摘要由CSDN通过智能技术生成

I'm having two lists x, y representing coordinates in 2D. For example x = [1,4,0.5,2,5,10,33,0.04] and y = [2,5,44,0.33,2,14,20,0.03]. x[i] and y[i] represent one point in 2D. Now I also have a list representing "heat" values for each (x,y) point, for example z = [0.77, 0.88, 0.65, 0.55, 0.89, 0.9, 0.8,0.95]. Of course x,y and z are much higher dimensional than the example.

Now I would like to plot a heat map in 2D where x and y represents the axis coordinates and z represents the color. How can this be done in python?

解决方案

This code produces a heat map. With a few more data points, the plot starts looking pretty nice and I've found it to be very quick in general even for >100k points.

import matplotlib.pyplot as plt

import matplotlib.tri as tri

import numpy as np

import math

x = [1,4,0.5,2,5,10,33,0.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值