matplotlib简单和两个箭头 [英] matplotlib simple and two head arrows

查看:51
本文介绍了matplotlib简单和两个箭头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作一个简单的箭头和一个两个箭头.我使用以下方法制作了一个简单的箭头,但我怀疑这是最简单的方法:

I would like to make a simple arrow and a two head arrow. I used the following to make a simple arrow, but I doubt this is the easiest method :

import matplotlib.pyplot as plt
arr_width = .009   #  I don't know what unit it is here.
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax1.plot(range(10))
ax1.arrow(1, 1, 0, .5, width = arr_width, head_width = 3 * arr_width, 
          head_length = 9 * arr_width)
plt.show()

我找不到用这种方法制作两个箭头的方法.

I can't find how to make two head arrows with this method.

推荐答案

您可以使用

You can create a double-headed arrow using the annotate method with blank text annotation and setting the arrowprops dict to include arrowstyle='<->' as shown below:

import matplotlib.pyplot as plt

plt.annotate(s='', xy=(1,1), xytext=(0,0), arrowprops=dict(arrowstyle='<->'))

plt.show()

这篇关于matplotlib简单和两个箭头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆