当前位置:网站首页>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)


边栏推荐
- 简述服务量化分析体系
- Record the errors reported when running fluent in the simulator
- Suffix derivation based on query object fields
- [mathematical modeling] ship three degree of freedom MMG model based on MATLAB [including Matlab source code 1925]
- Max of PHP FPM_ Some misunderstandings of children
- Torch learning notes (2) -- 11 common operation modes of tensor
- Scrapy爬虫框架
- “google is not defined” when using Google Maps V3 in Firefox remotely
- Briefly describe the quantitative analysis system of services
- 042. (2.11) do it when it's time to do it
猜你喜欢

Record the errors reported when running fluent in the simulator

Torch learning notes (3) -- univariate linear regression model (self training)

SQL custom collation
![leetcode:556. Next larger element III [simulation + change as little as possible]](/img/a0/12e5ee5d01d666acb4b75ada2e6fec.png)
leetcode:556. Next larger element III [simulation + change as little as possible]

Pan for in-depth understanding of the attention mechanism in CV

CV in transformer learning notes (continuously updated)

KINGS

Record: MySQL changes the time zone

Opencv learning notes (continuously updated)

我们做了一个智能零售结算平台
随机推荐
Chisel tutorial - 06 Phased summary: implement an FIR filter (chisel implements 4-bit FIR filter and parameterized FIR filter)
How about the Moco model?
Find the median of two positive arrays
leetcode:11. 盛最多水的容器【双指针 + 贪心 + 去除最短板】
利用可视化结果,点击出现对应的句子
Shell script return value with which output
12、 Service management
NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
Dart JSON编码器和解码器剖析
Read the paper glodyne global topology preserving dynamic network embedding
Caddy server agent
虚拟机和开发板互Ping问题
Common PostgreSQL commands
Day-27 database
There are several levels of personal income tax
Real time split network (continuous update)
Ping problem between virtual machine and development board
Differential constrained SPFA
[leetcode weekly race] game 300 - 6110 Number of incremental paths in the grid graph - difficult
Torch learning notes (4) -- torch's dynamic calculation diagram