python pyheatmap 패 키 지 를 이용 하여 열력 도 를 그립 니 다.구체 적 인 내용 은 다음 과 같 습 니 다.
import matplotlib.pyplot as plt
from pyheatmap.heatmap import HeatMap
def plot_data(filename):
with open(filename,'r') as fh:
data=fh.read().split('
')
xs = []
ys = []
data_test=[]
for line in data:
line=line.strip().split()
if len(line)>3:
opt, x, y = line[0], line[1], line[2]
if opt == '0':
xs.append(int(x))
ys.append(int(y))
data_test.append([int(x),int(y)])
plt.xlim()
plt.ylim()
plt.xlabel("x")
plt.ylabel("y")
plt.plot(xs, ys, 'ro')
plt.show()
return data_test
filename='track.log'
data=plot_data(filename)
#
hm = HeatMap(data)
hm.clickmap(save_as="hit.png")
hm.heatmap(save_as="heat.png")
#
hm2 = HeatMap(data)
hit_img2 = hm2.clickmap(base='base.png') # base.png
hit_img2.save("hit2.png")
마우스 위치 가 져 오기
import time
import pyautogui as pag
while True:
#print("Press Ctrl-C to end")
screenWidth, screenHeight = pag.size() #
#print(screenWidth,screenHeight)
x,y = pag.position() #
print(x,y)
time.sleep(0.1)
마우스 클릭 위치 읽 기
import pythoncom, pyHook
def onMouseEvent(event):
print("Position:", event.Position)
return True
def main():
hm = pyHook.HookManager()
hm.HookKeyboard()
hm.MouseAllButtonsDown = onMouseEvent
hm.MouseAllButtonsUp = onMouseEvent
hm.HookMouse()
pythoncom.PumpMessages()
if __name__ == "__main__":
main()
이상 이 바로 본 고의 모든 내용 입 니 다.여러분 의 학습 에 도움 이 되 고 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.