Python 标签插入轴散点图
我想通过对散点标记进行编号来标记此图中的散点标记,但我不知道如何获得插入轴坐标来放置标签Python 标签插入轴散点图,python,matplotlib,Python,Matplotlib,我想通过对散点标记进行编号来标记此图中的散点标记,但我不知道如何获得插入轴坐标来放置标签 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
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()
我对这种类型的图形没有太多经验,但我认为我可以使用我已经设置好的散点图的坐标并对其进行注释
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()
我不确定您希望输出是什么样子。请添加更多细节或图纸,以演示您希望输出的内容。