当前位置:网站首页>利用可视化结果,点击出现对应的句子
利用可视化结果,点击出现对应的句子
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)


边栏推荐
- Torch learning notes (1) -- 19 common ways to create tensor
- C enum contains value - C enum contains value
- Know what it is, and know why, JS object creation and inheritance [summary and sorting]
- A green plug-in that allows you to stay focused, live and work hard
- Why can deeplab v3+ be a God? (the explanation of the paper includes super detailed notes + Chinese English comparison + pictures)
- How to disable the clear button of ie10 insert text box- How can I disable the clear button that IE10 inserts into textboxes?
- Torch learning notes (2) -- 11 common operation modes of tensor
- High concurrency Architecture - read write separation
- 22.2.14 -- station B login with code -for circular list form - 'no attribute' - 'needs to be in path selenium screenshot deviation -crop clipping error -bytesio(), etc
- cipher
猜你喜欢
![leetcode:11. Container with the most water [double pointer + greed + remove the shortest board]](/img/d4/cbbaec40119be6cb5594899e348261.png)
leetcode:11. Container with the most water [double pointer + greed + remove the shortest board]

12、 Service management

Getting started with JDBC
Know what it is, and know why, JS object creation and inheritance [summary and sorting]

Implementation of cqrs architecture mode under Kratos microservice framework

PyTorch中在反向传播前为什么要手动将梯度清零?

Does SQL always report foreign key errors when creating tables?

What does a really excellent CTO look like in my eyes

There are several levels of personal income tax

FBI 警告:有人利用 AI 换脸冒充他人身份进行远程面试
随机推荐
Unity webgl optimization
12、 Service management
Compose LazyColumn 顶部添加控件
Recommend a simple browser tab
After the festival, a large number of people change careers. Is it still time to be 30? Listen to the experience of the past people
What problems can cross-border e-commerce sellers solve with multi platform ERP management system
How to quickly view the inheritance methods of existing models in torchvision?
【学术相关】顶级论文创新点怎么找?中国高校首次获CVPR最佳学生论文奖有感...
Web3 credential network project galaxy is better than nym?
达梦数据库的物理备份和还原简解
How does GCN use large convolution instead of small convolution? (the explanation of the paper includes super detailed notes + Chinese English comparison + pictures)
How to design a high concurrency system
199. Right view of binary tree - breadth search
Raft log replication
What does foo mean in programming?
Why can deeplab v3+ be a God? (the explanation of the paper includes super detailed notes + Chinese English comparison + pictures)
Data analysis is popular on the Internet, and the full version of "Introduction to data science" is free to download
Scrape crawler framework
Boost. Asio Library
Scrapy爬虫框架