繁体   English   中英

Label inset_axes 散点图 plot

[英]Label inset_axes scatter plot

我想通过对 ZD32FA6E1B78A9D4028953E60564A2AA4CZ 中的散点标记进行编号,但我不知道如何获取 inset_axes 坐标来放置标签。

import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots()
ax.plot(range(10))

x = np.random.rand(5)
y = np.random.rand(5)
labels = [str(num+1) for num in range(len(x))]

axin2 = ax.inset_axes(
    [5, 7, 2.3, 2.3], transform=ax.transData)
axin2.scatter(x, y)
plt.show()

我对这种类型的图没有太多经验,但我认为我可以使用我已经设置和注释的散点 plot 的坐标。

import matplotlib.pyplot as plt
import numpy as np

np.random.seed(2021)
fig, ax = plt.subplots(figsize=(12,9))
ax.plot(range(10))

x = np.random.rand(5)
y = np.random.rand(5)
labels = [str(num+1) for num in range(len(x))]

axin2 = ax.inset_axes(
    [5, 7, 2.3, 2.3], transform=ax.transData)
axin2.scatter(x, y)

for i in range(len(x)):
    axin2.annotate(str(i), xy=(x[i]+0.02,y[i]))
inset = axin2.transData
# print(inset)
plt.show()

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM