×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

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
Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

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