当前位置:网站首页>Using the visualization results, click to appear the corresponding sentence
Using the visualization results, click to appear the corresponding sentence
2022-07-03 19:01:00 【This Livermore is not too cold】
data format : The coordinates of the first two lines , Followed by a sentence
Reference link :Event handling and picking — Matplotlib 3.5.2 documentationhttps://matplotlib.org/stable/users/explain/event_handling.html
"""
-*- coding: utf-8 -*-
author: Hao Hu
@date 2022/6/30 7:49 PM
"""
import numpy as np
import matplotlib.pyplot as plt
def onpick(event):
thisline = event.artist
xdata = thisline.get_xdata()
ydata = thisline.get_ydata()
ind = event.ind
points = tuple(zip(xdata[ind], ydata[ind]))
print('the point of the sentence', x_to_sentence[xdata[ind][0]])
def get_pos():
""" Get point location information """
with open('inf.txt','r') as fp:
contents = fp.readlines()
pos = []
x_to_sentence = {}
for sample in contents:
x = float(sample.split()[0])
y = float(sample.split()[1])
pos.append([x,y])
sentence_str = ''
for sample in sample.split()[2:]:
sentence_str +=' '+sample
x_to_sentence[x] = sentence_str
return pos,x_to_sentence
def show_pic(pos,x_to_sentence):
fig, ax = plt.subplots()
ax.set_title('click and show sentence')
for i in range(len(pos)):
line, = ax.plot(pos[i][0], pos[i][1], 'o',
picker=True, pickradius=5) # 5 points tolerance
fig.canvas.mpl_connect('pick_event', onpick)
plt.show()
if __name__ == '__main__':
# fig.canvas.mpl_connect('pick_event', onpick)
# plt.show()
pos,x_to_sentence = get_pos()
show_pic(pos, x_to_sentence)
边栏推荐
- Processing of user input parameters in shell script
- CV in transformer learning notes (continuously updated)
- Typescript configuration
- Record the errors reported when running fluent in the simulator
- [mathematical modeling] ship three degree of freedom MMG model based on MATLAB [including Matlab source code 1925]
- High concurrency Architecture - read write separation
- Opencv learning notes (continuously updated)
- Flutter网络和数据存储框架搭建 -b1
- There are several levels of personal income tax
- Unity webgl optimization
猜你喜欢
组策略中开机脚本与登录脚本所使用的用户身份
Su embedded training - Day10
【光学】基于matlab介电常数计算【含Matlab源码 1926期】
Record the errors reported when running fluent in the simulator
Raft log replication
leetcode:11. 盛最多水的容器【雙指針 + 貪心 + 去除最短板】
多媒体NFT聚合平台OKALEIDO即将上线,全新的NFT时代或将来临
Does SQL always report foreign key errors when creating tables?
A green plug-in that allows you to stay focused, live and work hard
Read the paper glodyne global topology preserving dynamic network embedding
随机推荐
Getting started with JDBC
Recommend a simple browser tab
Simple solution of physical backup and restore of Damon database
简述服务量化分析体系
知其然,而知其所以然,JS 对象创建与继承【汇总梳理】
Record the errors reported when running fluent in the simulator
Record: pymysql is used in pycharm to connect to the database
VLAN experiment
There are several levels of personal income tax
High concurrency Architecture - read write separation
利用可视化结果,点击出现对应的句子
[Yu Yue education] world reference materials of Microbiology in Shanghai Jiaotong University
Web3 credential network project galaxy is better than nym?
12、 Service management
Torch learning notes (4) -- torch's dynamic calculation diagram
Multifunctional web file manager filestash
Flutter网络和数据存储框架搭建 -b1
Raft 日志复制
DriveSeg:动态驾驶场景分割数据集
Su embedded training - Day10