python pyheatmap包繪制熱力圖
利用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)文章
Python腳本實(shí)現(xiàn)網(wǎng)卡流量監(jiān)控
這篇文章主要介紹了Python腳本實(shí)現(xiàn)網(wǎng)卡流量監(jiān)控,本文直接給出實(shí)現(xiàn)代碼,需要的朋友可以參考下2015-02-02數(shù)據(jù)挖掘之Apriori算法詳解和Python實(shí)現(xiàn)代碼分享
這篇文章主要介紹了數(shù)據(jù)挖掘之Apriori算法詳解和Python實(shí)現(xiàn)代碼分享,本文先是對(duì)Apriori算法做了詳細(xì)介紹,然后給出了Python版實(shí)現(xiàn)代碼,需要的朋友可以參考下2014-11-11解決使用python print打印函數(shù)返回值多一個(gè)None的問題
這篇文章主要介紹了解決使用python print打印函數(shù)返回值多一個(gè)None的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-04-04Python接入MySQL實(shí)現(xiàn)增刪改查的實(shí)戰(zhàn)記錄
這篇文章主要給大家介紹了關(guān)于Python接入MySQL實(shí)現(xiàn)增刪改查的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-03-03Python實(shí)現(xiàn)操縱控制windows注冊(cè)表的方法分析
這篇文章主要介紹了Python實(shí)現(xiàn)操縱控制windows注冊(cè)表的方法,結(jié)合實(shí)例形式分析了Python使用_winreg模塊以及win32api模塊針對(duì)Windows注冊(cè)表操作相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下2019-05-05Python實(shí)現(xiàn)批量壓縮文件/文件夾zipfile的使用
本文主要介紹了Python實(shí)現(xiàn)批量壓縮文件/文件夾zipfile的使用,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-09-09使用Python Typing模塊提升代碼可讀性和健壯性實(shí)例探索
這篇文章主要為大家介紹了使用Python Typing模塊提升代碼可讀性和健壯性實(shí)例探索,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2024-01-01Python 的 f-string 可以連接字符串與數(shù)字的原因解析
這篇文章主要介紹了Python 的 f-string 可以連接字符串與數(shù)字的原因解析,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-02-02Python BeautifulSoup中文亂碼問題的2種解決方法
這篇文章主要介紹了Python BeautifulSoup中文亂碼問題的2種解決方法,需要的朋友可以參考下2014-04-04