Python | Dual Headed Arrow in Plots

In this tutorial, we are going to learn how to draw a dual headed arrow in python using matplotlib?
Submitted by Anuj Singh, on August 08, 2020

We can use a single-headed arrow function twice with precise positioning for plotting dual-headed arrows. The following example illustrates how we can use the function matplotlib.pyplot.arrow() to draw dual-headed arrows. Moreover, we can change the color as shown in the second example.

Example:

Python | Dual Headed Arrow in Plots

Python code for dual headed arrow in plots

import matplotlib.pyplot as plt

# Arrows

plt.figure()
plt.title('The Dual Headed Arrow')
plt.arrow(0.3, 0.1, 0.4, 0.7, color='blue',
          head_length = 0.07, head_width = 0.025, 
          length_includes_head = True)

plt.arrow(0.7, 0.8, -0.4, -0.7, color='blue',
          head_length = 0.07, head_width = 0.025, 
          length_includes_head = True)
plt.show()

plt.figure()
plt.title('Two Dual Headed Arrow')
plt.arrow(0.3, 0.1, 0.4, 0.7, color='blue',
          head_length = 0.07, head_width = 0.025, 
          length_includes_head = True)

plt.arrow(0.7, 0.8, -0.4, -0.7, color='blue',
          head_length = 0.07, head_width = 0.025, 
          length_includes_head = True)

plt.arrow(0.2, 0.3, 0.7, 0.0, color='green',
          head_length = 0.07, head_width = 0.025, 
          length_includes_head = True)

plt.arrow(0.9, 0.3, -0.7, 0.0, color='green',
          head_length = 0.07, head_width = 0.025, 
          length_includes_head = True)
plt.show()

Output:

Output is as Figure





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.