python - Matplotlib arrow in loglog plot -


i'm trying draw arrow loglog plot matplotlib, looks this:

enter image description here

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() 

enter image description here

note may need adjust axes limits fit arrow plot. here had change ylim.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -