python - Matplotlib arrow in loglog plot -
i'm trying draw arrow loglog plot matplotlib, looks this:
i know has been suggested turn off axis (matplotlib: draw vertical arrow in log-log plot), need axes. in addition, suggestion did not seem change (apart turning axes off, expected):
plt.figure();plt.loglog([1,10,60],[1,0.1,0.005]) plt.axis('off') plt.arrow(2,0.002,5,0.098,'k',head_length=0.3)
my work around far has been create invisible inset (meaning: axes off) linear axes environment , plot arrow in inset, works bit unpleasant. there simpler way? or people recommend add these type of additional features eg. inkscape, after main plot done?
you can use plt.annotate
rather plt.arrow
. noted in documentation plt.arrow
:
the resulting arrow affected axes aspect ratio , limits. may produce arrow head not square stem. create arrow head square stem, use
annotate()
for example:
import matplotlib.pyplot plt plt.figure() plt.loglog([1,10,60],[1,0.1,0.005]) plt.annotate('', xy=(5, 0.098), xytext=(2, 0.002), arrowprops=dict(facecolor='black', shrink=0.), ) plt.ylim(0.001, 10) plt.show()
note may need adjust axes limits fit arrow plot. here had change ylim
.
Comments
Post a Comment