当前位置:网站首页>利用可视化结果,点击出现对应的句子
利用可视化结果,点击出现对应的句子
2022-07-03 18:50:00 【这个利弗莫尔不太冷】
数据格式:前两行为点坐标,后面为句子

"""
-*- 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():
"""得到点位置信息"""
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)


边栏推荐
- 2022-2028 global solid phase extraction column industry research and trend analysis report
- Multifunctional web file manager filestash
- FBI 警告:有人利用 AI 换脸冒充他人身份进行远程面试
- [combinatorics] exponential generating function (properties of exponential generating function | exponential generating function solving multiple set arrangement)
- Boost. Asio Library
- Reappearance of ASPP (atlas spatial pyramid pooling) code
- Recent learning experience
- 變化是永恒的主題
- Transformer T5 model read slowly
- Read the paper glodyne global topology preserving dynamic network embedding
猜你喜欢

Why can deeplab v3+ be a God? (the explanation of the paper includes super detailed notes + Chinese English comparison + pictures)

The online customer service system developed by PHP is fully open source without encryption, and supports wechat customer service docking

Data analysis is popular on the Internet, and the full version of "Introduction to data science" is free to download

The installation path cannot be selected when installing MySQL 8.0.23
![Leetcode: 11. Récipient contenant le plus d'eau [double pointeur + cupidité + enlèvement de la plaque la plus courte]](/img/d4/cbbaec40119be6cb5594899e348261.png)
Leetcode: 11. Récipient contenant le plus d'eau [double pointeur + cupidité + enlèvement de la plaque la plus courte]

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

leetcode:11. 盛最多水的容器【双指针 + 贪心 + 去除最短板】

2022.02.11

Implementation of cqrs architecture mode under Kratos microservice framework

What does a really excellent CTO look like in my eyes
随机推荐
变化是永恒的主题
235. 二叉搜索樹的最近公共祖先【lca模板 + 找路徑相同】
平淡的生活里除了有扎破皮肤的刺,还有那些原本让你魂牵梦绕的诗与远方
Processing of user input parameters in shell script
Typescript configuration
知其然,而知其所以然,JS 对象创建与继承【汇总梳理】
Recommend a simple browser tab
VLAN experiment
编程中常见的 Foo 是什么意思?
189. Rotation array
Torch learning notes (5) -- autograd
What is the function of registering DLLs- What does registering a DLL do?
Implementation of cqrs architecture mode under Kratos microservice framework
硬盘监控和分析工具:Smartctl
Le changement est un thème éternel
SQL: special update operation
shell 脚本中关于用户输入参数的处理
Boost. Asio Library
The online customer service system developed by PHP is fully open source without encryption, and supports wechat customer service docking
application