How to draw scale-independent arrows with matplotlib

痴心易碎 提交于 2019-12-24 03:34:43

问题


I have drawn a trajectory plot in python using matplotlib of a boat like so:

Now I want to add some arrows, like wind direction, true heading etc. However I want the arrows to have the same size no matter which zoom-level the plot is at. I tried matplotlib.pyplot.arrow, however there I have to define the length of the arrows. I could make matplotlib.pyplot.arrow work, but then I'd have to get the height and width of the plot, and scale my arrows accordingly, so I wondered if there was a better way to obtain scale-independent arrows for these points?


回答1:


You want to use matplotlib.axes.Axes.annotate instead. See the docs for more info!

Basically, set the xycoords parameter to "axes fraction" to instruct it to plot using relative fraction of the axes itself rather than data coordinates.



来源:https://stackoverflow.com/questions/57221054/how-to-draw-scale-independent-arrows-with-matplotlib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!