×

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 mu in Plot Label

In this article, we are going to learn how to add μ (mu) letter in the plot label in Python?
Submitted by Anuj Singh, on July 14, 2020

How to add mu in Plot Label?

μ (Mu) is very often used greek mathematical letters and has a higher repetition in probability. In this article, we are going to add μ using a command in matplotlib.

Syntax

plt.text(3, 0.4, r'$\mu=100$')
#Adding μ as text
Python | Adding mu in Plot Label (1)
plt.title('Errorbar with 'r'$\mu=100$')
#Adding μ in title of the figure
Python | Adding mu in Plot Label (2)
plt.xlabel('Time ('r'$\mu=100)$')
#Adding μ in title of the figure
Python | Adding mu in Plot Label (3)
plt.ylabel('Variation ('r'$\mu=100)$')
#Adding μ in title of the figure
Python | Adding mu in Plot Label (4)

Python program for adding mu in plot label

import numpy as np
import matplotlib.pyplot as plt

x = np.arange(0.1, 5, 0.1)
y = np.exp(-x)
yerr = 0.1 + 0.1 * np.sqrt(x)

# In text
plt.figure()
plt.errorbar(x, y, yerr=yerr)
plt.title('Errorbar')
plt.text(3, 0.4, r'$\mu=100$')
plt.show()

# In title
plt.figure()
plt.errorbar(x, y, yerr=yerr)
plt.title('Errorbar with 'r'$\mu=100$')
plt.show()

# In x-axis label
plt.figure()
plt.errorbar(x, y, yerr=yerr)
plt.xlabel('Time ('r'$\mu=100)$')
plt.show()

# In y-axis label
plt.figure()
plt.errorbar(x, y, yerr=yerr)
plt.ylabel('Variation ('r'$\mu=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.