×

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 | Adding Psi in Plot Label

Here, we are going to learn how to add psi in plot label in Python?
Submitted by Anuj Singh, on August 07, 2020

Ψ (Psi) is very often used greek mathematical letters. They are mostly used in physics and other mathematical expressions, especially, when there is topic related change (for example charge and electrodynamics) and therefore, they have registered importance in languages.

Therefore, matplotlib has defined a command for usage.

In this article, we are going to add Ψ using a command in matplotlib.

plt.text(3, 0.4, r'$\Psi=100$')
#Adding Ψ as text
Python | Adding Psi in Plot Label (1)
plt.title(‘Psi 'r'$\Psi=100$')
#Adding Ψ in title of the figure
Python | Adding Psi in Plot Label (2)
plt.xlabel('Psi ('r'$\Psi=100)$')
#Adding Ψ in x axis label of the figure
Python | Adding Psi in Plot Label (3)
plt.ylabel('Psi ('r'$\Psi=100)$')
#Adding Ψ in y axis label of the figure
Python | Adding Psi in Plot Label (4)

Python code for adding psi in plot label

import numpy as np
import matplotlib.pyplot as plt

x = np.arange(10)
y = np.cos(x)*np.exp(x/5)

#  Psi
# In text
plt.figure()
plt.plot(x,y, '-o', color=  'purple')
plt.title('Psi')
plt.text(3, -2.2, r'$\Psi=100$')
plt.show()

# In title
plt.figure()
plt.plot(x,y, '-o', color=  'purple')
plt.title('  Psi 'r'$\Psi=100$')
plt.show()

# In x-axis label
plt.figure()
plt.plot(x,y, '-o', color=  'purple')
plt.xlabel('  Psi ('r'$\Psi=100)$')
plt.show()

# In y-axis label
plt.figure()
plt.plot(x,y, '-o', color=  'purple')
plt.ylabel('  Psi ('r'$\Psi=100)$')
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.