2012-12-18 10 views
5

में समान आकार के तीरहेड मैं matplotlib के साथ तीर प्लॉट करना चाहता हूं ताकि वास्तविक तीर के आकार के बावजूद प्रत्येक तीर का बराबर आकार का हो।matplotlib

उदाहरण:

तीर matplotlib.pyplot.Arrow का उपयोग कर तैयार कर रहे हैं():

# p is the point of origin, pdiff the direction   
arr = plt.Arrow(p[0], p[1], pdiff[0], pdiff[1], fc=color, width=0.4) 
plt.gca().add_patch(arr) 
+2

आप कोड जहां आप वास्तव में तीर ड्राइंग कर रहे हैं दिखा सकते हैं यहाँ एक उदाहरण है? – mgilson

उत्तर

5

आप pylab.arrow (याके बाद हैं)), तो आप head_width और head_length निर्दिष्ट कर सकते हैं ताकि वे तीर के आकार के सापेक्ष न हों।

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

कौन सा पैदा करता है:

enter image description here

+0

यह एक अच्छा उदाहरण है! –