Right and Left Handed Arrows in Python Plot

matplotlib.pyplot.arrow(): Here, we are going to learn about the right and left handed arrows in Python with examples.
Submitted by Anuj Singh, on July 22, 2020

In this tutorial, we are going to explore two additional types of arrows that are Right Handed and Left Handed arrows. We can use the command shape in the function matplotlib.pyplot.arrow() for plotting Right and Left Handed arrows in a figure.

The following example illustrates the implementation.

matplotlib.pyplot.arrow(
    0, 
    0, 
    0.5, 
    0.5, 
    shape = 'left' head_width=0.05, 
    head_length=0.1)

#shape = 'right' : Right Handed Arrow
#shape = 'left' : Left Handed Arrow
Right and Left Handed Arrows in Python Plot (1)

Right and Left Handed Arrows in Python Plot (2)

Right and Left Handed Arrows in Python Plot (3)

Right and Left Handed Arrows in Python Plot (4)

Code for Right and Left Handed Arrows in Python Plot

import matplotlib.pyplot as plt

plt.figure()
plt.arrow(0, 0, 0.5, 0.5, shape='left', head_width=0.05, head_length=0.1)
plt.title('Left Shaped Arrow')
plt.show()


plt.figure()
plt.arrow(0, 0, 0.5, 0.5, shape='right', head_width=0.05, head_length=0.1)
plt.title('Right Shaped Arrow')
plt.show()

plt.figure()
plt.arrow(0.2, 0.6, 0.4, 0.0, shape='right', head_width=0.05, head_length=0.1)
plt.arrow(0.2, 0.58, 0.4, 0.0, shape='left', head_width=0.05, head_length=0.1)
plt.title('Arrow - Pair')
plt.show()

Output:

Output is as figure



Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.