python pyheatmap包繪制熱力圖
更新時(shí)間:2018年11月09日 08:35:18 作者:Jepson2017
這篇文章主要為大家詳細(xì)介紹了python pyheatmap包繪制熱力圖,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
利用python pyheatmap包繪制熱力圖,供大家參考,具體內(nèi)容如下
import matplotlib.pyplot as plt
from pyheatmap.heatmap import HeatMap
def plot_data(filename):
with open(filename,'r') as fh:
data=fh.read().split('\n')
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")
# 繪制帶背景的點(diǎn)擊熱圖
hm2 = HeatMap(data)
hit_img2 = hm2.clickmap(base='base.png') # base.png為背景圖片
hit_img2.save("hit2.png")
獲取鼠標(biāo)位置
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() #獲取當(dāng)前鼠標(biāo)的位置
print(x,y)
time.sleep(0.1)
讀取鼠標(biāo)點(diǎn)擊位置
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()
以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
pytorch如何保存訓(xùn)練模型參數(shù)并實(shí)現(xiàn)繼續(xù)訓(xùn)練
這篇文章主要介紹了pytorch如何保存訓(xùn)練模型參數(shù)并實(shí)現(xiàn)繼續(xù)訓(xùn)練問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-09-09
Python+django實(shí)現(xiàn)文件下載
本文是python+django系列的第二篇文章,主要是講述是先文件下載的方法和代碼,有需要的小伙伴可以參考下。2016-01-01
基于Python和C++實(shí)現(xiàn)刪除鏈表的節(jié)點(diǎn)
這篇文章主要介紹了基于Python和C++實(shí)現(xiàn)刪除鏈表的節(jié)點(diǎn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-07-07
淺談Python從全局與局部變量到裝飾器的相關(guān)知識(shí)
今天給大家?guī)淼氖顷P(guān)于Python的相關(guān)知識(shí),文章圍繞著Python從全局與局部變量到裝飾器的相關(guān)知識(shí)展開,文中有非常詳細(xì)的介紹及代碼示例,需要的朋友可以參考下2021-06-06
python2與python3爬蟲中g(shù)et與post對(duì)比解析
這篇文章主要介紹了python2與python3爬蟲中g(shù)et與post對(duì)比解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-09-09

