Python | Drawing Chemical Reaction using Arrow (Matplotlib Arrow Example)

Here, we are going to learn how to draw chemical reaction using arrow (matplotlib arrow example)?
Submitted by Anuj Singh, on July 31, 2020

Arrows are very frequently used in drawing chemical reactions. Therefore, in this article, we are going to illustrate two different examples of how to draw a chemical reaction in python using matplotlib.

Example 1 is showing a chemical reaction with equilibrium between reactant A and product B.

Python | Drawing Chemical Reaction using Arrow (1)

Example 2 is showing a chemical reaction where reactant A is converted into product B.

Python | Drawing Chemical Reaction using Arrow (2)

Python code for drawing chemical reaction using arrow

import matplotlib.pyplot as plt

plt.figure()
plt.arrow(0.3, 0.4, 0.3, 0, shape='right', head_width=0.05, head_length=0.07)
plt.text(0.25, 0.37, 'A', fontsize=18)

plt.arrow(0.67, 0.38, -0.3, 0, shape='right', head_width=0.05, head_length=0.07)
plt.text(0.7, 0.37, 'B', fontsize=18)

plt.title('Chemical Reaction Example 1')
plt.box()
plt.show()

plt.figure()
plt.arrow(0.3, 0.4, 0.3, 0, head_width=0.05, head_length=0.07)
plt.text(0.25, 0.375, 'A', fontsize=18)
plt.text(0.7, 0.375, 'B', fontsize=18)
plt.title('Chemical Reaction Example 2')
plt.box()
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.