kullanın annotate
. Aslında, text
'u neredeyse hiç kullanmıyorum. Veri koordinatlarına bir şeyler koymak istediğimde bile, genellikle annotate
ile çok daha kolay olan noktalarda bazı sabit mesafelerle dengelemek istiyorum. Eğer biraz köşesinden offset isterseniz
import matplotlib.pyplot as plt
fig, axes = plt.subplots(nrows=2, subplot_kw=dict(aspect=1))
axes[0].plot(range(1, 4))
axes[1].plot(range(10, 40, 10), range(1, 4))
for ax in axes:
ax.annotate('Test', xy=(1, 0), xycoords='axes fraction', fontsize=16,
horizontalalignment='right', verticalalignment='bottom')
plt.show()
, bir nasıl kontrol değerlerine textcoords
xytext
kwarg yoluyla ofset (ve belirtebilirsiniz: Hızlı bir örnek olarak
xytext
yorumlanır). Ofset Eğer eksen altına yerleştirin çalışıyorsanız
import matplotlib.pyplot as plt
fig, axes = plt.subplots(nrows=2, subplot_kw=dict(aspect=1))
axes[0].plot(range(1, 4))
axes[1].plot(range(10, 40, 10), range(1, 4))
for ax in axes:
ax.annotate('Test', xy=(1, 0), xycoords='axes fraction', fontsize=16,
xytext=(-5, 5), textcoords='offset points',
ha='right', va='bottom')
plt.show()
kullanabileceğiniz it a set yerleştirmek için: Ben de burada horizontalalignment
ve verticalalignment
için ha
ve va
kısaltmalar kullanıyorum noktaları aşağıda mesafe:
import matplotlib.pyplot as plt
fig, axes = plt.subplots(nrows=2, subplot_kw=dict(aspect=1))
axes[0].plot(range(1, 4))
axes[1].plot(range(10, 40, 10), range(1, 4))
for ax in axes:
ax.annotate('Test', xy=(1, 0), xycoords='axes fraction', fontsize=16,
xytext=(0, -15), textcoords='offset points',
ha='right', va='top')
plt.show()
Daha fazla bilgi için Matplotlib annotation guide da bir göz atın.
Bu harika bir cevap ve örnekler. Metin yerine not eklemeyi kullanmaya çalışacağım. Çok teşekkür ederim. – Tetsuro
Harika cevap! Teşekkürler! – HyperCube