python - 控制 matplotlib 图像的焦点
问题描述
我正在尝试使用 PCA 来注释我在 2d 中建模 Word2Vec 的单词。该变量result
包含以下值:
array([[ 0.01632784, 0.01212493],
[ 0.00070532, 0.01451515],
[-0.0055863 , -0.00661636],
[-0.01106532, -0.0157193 ],
[-0.01473162, 0.00611054],
[-0.01046929, 0.01837107],
[-0.01007252, -0.00692229],
[ 0.00529983, -0.0078546 ],
[ 0.00972514, -0.0030543 ],
[ 0.01812323, -0.01013864],
[-0.00453239, -0.00411107],
[-0.00108769, -0.00255492],
[ 0.0009 , 0.00191122],
[ 0.00646378, 0.00393857]], dtype=float32)
清单words
是:
'Text',
'of',
'the',
'first',
'document',
'second',
'made',
'longer',
'Number',
'three',
'This',
'is',
'number',
'four']
我试图在其坐标中绘制单词的部分代码:
import matplotlib.pyplot as plt
for i,word in enumerate(words):
plt.annotate(word, xy=(result[i,0], result[i,1]))
plt.show()
当我尝试绘制这些单词时,x 和 y 轴分别从 (0,1) 和 (0,1) 显示。如果我只能从 (0,0.2) 和 (0,0.2) 或任何其他方式显示图像中存在点的部分,那会更好。
解决方案
推荐阅读
- git - 通过 WSL 克隆 GitHub 存储库失败
- r - 在 Rmarkdown 到 pdf 的预览中的方程式编号?
- kubernetes - 如何在 nginx 入口中的子路径上公开哨兵?
- php - 如果基本 url 包含端口号,则不会加载资产 - codeigniter 4
- excel - 搜索项目列表的功能
- entity-framework - AddOpenIdConnect 与本地 UserManager
- apache-kafka - Kafka什么时候轮换partition leader?我们有任何财产来控制它吗?
- c - 使用 SVG 在 C 中递归的谢尔宾斯基地毯
- python - python3计数器,它也平均滑动窗口中的索引位置
- python-3.x - 使用用户定义的 python 函数。“ModuleNotFoundError”,Tableau,Tabpy