当前位置:网站首页>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)
边栏推荐
- 【疾病识别】基于matlab GUI机器视觉肺癌检测系统【含Matlab源码 1922期】
- Ping problem between virtual machine and development board
- Reading a line from ifstream into a string variable
- Simulation scheduling problem of SystemVerilog (1)
- SSM integration - joint debugging of front and rear protocols (list function, add function, add function status processing, modify function, delete function)
- 达梦数据库的物理备份和还原简解
- Processing of user input parameters in shell script
- Chisel tutorial - 06 Phased summary: implement an FIR filter (chisel implements 4-bit FIR filter and parameterized FIR filter)
- Analysis of dart JSON encoder and decoder
- FBI 警告:有人利用 AI 换脸冒充他人身份进行远程面试
猜你喜欢
leetcode:11. Container with the most water [double pointer + greed + remove the shortest board]
Compose LazyColumn 顶部添加控件
【数学建模】基于matlab船舶三自由度MMG模型【含Matlab源码 1925期】
235. 二叉搜索树的最近公共祖先【lca模板 + 找路径相同】
Flutter network and data storage framework construction-b1
Dart JSON编码器和解码器剖析
[Yu Yue education] theoretical mechanics reference materials of Shanghai Jiaotong University
FBI警告:有人利用AI换脸冒充他人身份进行远程面试
Web3 credential network project galaxy is better than nym?
Kratos微服务框架下实现CQRS架构模式
随机推荐
知其然,而知其所以然,JS 对象创建与继承【汇总梳理】
Record: writing MySQL commands
[academic related] how to find the innovation of top papers? Chinese universities won the CVPR Best Student Thesis Award for the first time
达梦数据库的物理备份和还原简解
How to design a high concurrency system
SQL: special update operation
论文阅读 GloDyNE Global Topology Preserving Dynamic Network Embedding
硬盘监控和分析工具:Smartctl
Multifunctional web file manager filestash
Zhengda futures news: soaring oil prices may continue to push up global inflation
Does SQL always report foreign key errors when creating tables?
SSM整合-前后台协议联调(列表功能、添加功能、添加功能状态处理、修改功能、删除功能)
Find the median of two positive arrays
Su embedded training - Day10
php-fpm的max_chindren的一些误区
Torch learning notes (7) -- take lenet as an example for dataload operation (detailed explanation + reserve knowledge supplement)
Which do MySQL and Oracle learn?
多媒体NFT聚合平台OKALEIDO即将上线,全新的NFT时代或将来临
math_泰勒公式
东数西算拉动千亿产业,敢啃“硬骨头”的存储厂商才更有机会