簡體   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