Python matplotlib中大小相等的箭头
我希望使用matplotlib绘制箭头,以便无论箭头的实际大小如何,每个箭头都具有相同的大小 示例:Python matplotlib中大小相等的箭头,python,matplotlib,Python,Matplotlib,我希望使用matplotlib绘制箭头,以便无论箭头的实际大小如何,每个箭头都具有相同的大小 示例: 当前箭头: 所需箭头: 使用matplotlib.pyplot.Arrow()绘制箭头。: 您在pylab.arrow(或FancyArrow)之后,可以指定头部宽度和头部长度,以便它们与箭头的大小无关。以下是一个例子: import math import pylab pylab.plot(range(11), range(11)) opt = {'head_width': 0.4
- 当前箭头:
- 所需箭头:
matplotlib.pyplot.Arrow()绘制箭头。
:
您在
pylab.arrow
(或FancyArrow
)之后,可以指定头部宽度
和头部长度
,以便它们与箭头的大小无关。以下是一个例子:
import math
import pylab
pylab.plot(range(11), range(11))
opt = {'head_width': 0.4, 'head_length': 0.4, 'width': 0.2,
'length_includes_head': True}
for i in xrange(1, 360, 20):
x = math.radians(i)*math.cos(math.radians(i))
y = math.radians(i)*math.sin(math.radians(i))
# Here is your method.
arr = pylab.Arrow(4, 6, x, y, fc='r', alpha=0.3)
pylab.gca().add_patch(arr)
# Here is the proposed method.
pylab.arrow(4, 6, x, y, alpha=0.8, **opt)
pylab.show()
产生:
你能告诉我你在哪里画箭头吗?这是一个很好的例子!
import math
import pylab
pylab.plot(range(11), range(11))
opt = {'head_width': 0.4, 'head_length': 0.4, 'width': 0.2,
'length_includes_head': True}
for i in xrange(1, 360, 20):
x = math.radians(i)*math.cos(math.radians(i))
y = math.radians(i)*math.sin(math.radians(i))
# Here is your method.
arr = pylab.Arrow(4, 6, x, y, fc='r', alpha=0.3)
pylab.gca().add_patch(arr)
# Here is the proposed method.
pylab.arrow(4, 6, x, y, alpha=0.8, **opt)
pylab.show()