当前位置:网站首页>利用可视化结果,点击出现对应的句子
利用可视化结果,点击出现对应的句子
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)
边栏推荐
- PHP determines which constellation it belongs to today
- How about the Moco model?
- High concurrency Architecture - read write separation
- SSM integration - joint debugging of front and rear protocols (list function, add function, add function status processing, modify function, delete function)
- leetcode:556. Next larger element III [simulation + change as little as possible]
- Integrated easy to pay secondary domain name distribution system
- PyTorch中在反向传播前为什么要手动将梯度清零?
- 2022-2028 global solid phase extraction column industry research and trend analysis report
- Torch learning notes (2) -- 11 common operation modes of tensor
- 042. (2.11) do it when it's time to do it
猜你喜欢
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
235. 二叉搜索樹的最近公共祖先【lca模板 + 找路徑相同】
235. Ancêtre public le plus proche de l'arbre de recherche binaire [modèle LCA + même chemin de recherche]
Record: writing MySQL commands
Install apache+php+mysql+phpmyadmin xampp and its error resolution
VLAN experiment
Getting started with JDBC
Zhengda futures news: soaring oil prices may continue to push up global inflation
虚拟机和开发板互Ping问题
平淡的生活里除了有扎破皮肤的刺,还有那些原本让你魂牵梦绕的诗与远方
随机推荐
What does foo mean in programming?
Suffix derivation based on query object fields
Typescript official website tutorial
Torch learning notes (2) -- 11 common operation modes of tensor
Why can deeplab v3+ be a God? (the explanation of the paper includes super detailed notes + Chinese English comparison + pictures)
High concurrency architecture cache
Scrapy爬虫框架
There are several levels of personal income tax
2022-2028 global solid phase extraction column industry research and trend analysis report
__ Weak and__ The difference between blocks
多媒体NFT聚合平台OKALEIDO即将上线,全新的NFT时代或将来临
Which do MySQL and Oracle learn?
达梦数据库的物理备份和还原简解
Flutter网络和数据存储框架搭建 -b1
Unity2018 to wechat games without pictures
变化是永恒的主题
NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
Record: install MySQL on ubuntu18.04
Recommend a simple browser tab
我们做了一个智能零售结算平台