我从调查中得到一组坐标/点击。我想创建一个这些点击的热图,但带有背景图片。
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()
"""
当我这样做时,我有两个单独的图像,而不是背景上的imgae,热图叠加在图像上。
制作热图时有没有办法拍摄背景图片?我是新来的和编程,请说如果我需要解释更多。
谢谢!