Home »
Python »
Python Data Visualization
Python | Adding Epsilon in Plot Label
Here, we are going to learn how to add epsilon in plot label in Python?
Submitted by Anuj Singh, on August 07, 2020
ε (epsilon) 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.
1. epsilon
plt.text(3, 0.4, r'$\epsilon=100$')
#Adding ε as text
plt.title('epsilon 'r'$\epsilon=100$')
#Adding ε in title of the figure
plt.xlabel('epsilon ('r'$\epsilon=100)$')
#Adding ε in x axis label of the figure
plt.ylabel('epsilon ('r'$\epsilon=100)$')
#Adding ε in y axis label of the figure
Python code for adding epsilon in plot label
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(10)
y = np.cos(x)*np.exp(x/5)
# epsilon
# In text
plt.figure()
plt.plot(x,y, 'o', color= 'purple')
plt.title('epsilon')
plt.text(4, 5, r'$\epsilon=100$')
plt.show()
# In title
plt.figure()
plt.plot(x,y, 'o', color= 'purple')
plt.title(' epsilon 'r'$\epsilon=100$')
plt.show()
# In x-axis label
plt.figure()
plt.plot(x,y, 'o', color= 'purple')
plt.xlabel(' epsilon ('r'$\epsilon=100)$')
plt.show()
# In y-axis label
plt.figure()
plt.plot(x,y, 'o', color= 'purple')
plt.ylabel(' epsilon ('r'$\epsilon=100)$')
plt.show()
Output:
Output is as Figure