Python 使用dataframe对值进行排序和打印

Python 使用dataframe对值进行排序和打印,python,matplotlib,heatmap,Python,Matplotlib,Heatmap,我有一组来自调查的坐标/点击。我想创建这些点击的热图,但有一个背景图像 import pandas as pd import numpy as np import matplotlib.pyplot as plt import matplotlib.image as mpimg from PIL import Image #import the excel file file = 'pidxyemo.xlsx' xl = pd.ExcelFile(file) df1 = xl.parse('

我有一组来自调查的坐标/点击。我想创建这些点击的热图,但有一个背景图像

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
from PIL import Image

#import the excel file 
file = 'pidxyemo.xlsx'
xl = pd.ExcelFile(file)
df1 = xl.parse('Sheet1')
df2 = df1[np.isfinite(df1['X'])]
numpyMatrix = df2.as_matrix() #<---I have my data points here 

#the image I would like to use as background
img = Image.open("C:\\Users\\Judita\\Desktop\\body.png")

#I saw that someone used the following to make a heat map 
"""
x = np.random.randn(88)
y = np.random.randn(88)

heatmap, xedges, yedges = np.histogram2d(x, y, bins=50)
extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]


plt.imshow(heatmap.T, extent=extent, origin='lower')
plt.show()
"""
将熊猫作为pd导入
将numpy作为np导入
将matplotlib.pyplot作为plt导入
将matplotlib.image导入为mpimg
从PIL导入图像
#导入excel文件
文件='pidxyemo.xlsx'
xl=pd.ExcelFile(文件)
df1=xl.parse('Sheet1')
df2=df1[np.isfinite(df1['X'])]

numpyMatrix=df2.as_matrix()#如果热图叠加在图像上,您如何仍然希望看到图像?您需要使热图透明(可能通过定义颜色范围使其透明)并将该图像粘贴到背景图像上(搜索粘贴图像pil)。绝对可行。(只是一些想法)嘿,谢谢你的回复。图像是人体的轮廓,我需要显示点击的热图@安东,谢谢,我将尝试将热图制作为图像并粘贴到背景上。:)@用户8349986没有问题。回到这里,例如,当你有两个大小相等的图像,并粘贴它们,但你不能让透明度的工作。如果你能提供两个图像样本,我想会有人帮你。如果热图叠加在图像上,你怎么还能看到图像?你需要使热图透明(可能通过定义colorrange使其透明)并将该图像粘贴到背景图像上(搜索paste image pil). 绝对可行。(只是一些想法)嘿,谢谢你的回复。图像是人体的轮廓,我需要显示点击的热图@安东,谢谢,我将尝试将热图制作为图像并粘贴到背景上。:)@用户8349986没有问题。回到这里,例如,当你有两个大小相等的图像,并粘贴它们,但你不能让透明度的工作。我想如果你能提供两个图像样本,会有人帮你的。