
- Matplotlib Tutorial
- Matplotlib - Home
- Matplotlib - Introduction
- Matplotlib - Environment Setup
- Matplotlib - Anaconda distribution
- Matplotlib - Jupyter Notebook
- Matplotlib - Pyplot API
- Matplotlib - Simple Plot
- Matplotlib - PyLab module
- Object-oriented Interface
- Matplotlib - Figure Class
- Matplotlib - Axes Class
- Matplotlib - Multiplots
- Matplotlib - Subplots() Function
- Matplotlib - Subplot2grid() Function
- Matplotlib - Grids
- Matplotlib - Formatting Axes
- Matplotlib - Setting Limits
- Setting Ticks and Tick Labels
- Matplotlib - Twin Axes
- Matplotlib - Bar Plot
- Matplotlib - Histogram
- Matplotlib - Pie Chart
- Matplotlib - Scatter Plot
- Matplotlib - Contour Plot
- Matplotlib - Quiver Plot
- Matplotlib - Box Plot
- Matplotlib - Violin Plot
- Three-dimensional Plotting
- Matplotlib - 3D Contour Plot
- Matplotlib - 3D Wireframe plot
- Matplotlib - 3D Surface plot
- Matplotlib - Working With Text
- Mathematical Expressions
- Matplotlib - Working with Images
- Matplotlib - Transforms
- Matplotlib Useful Resources
- Matplotlib - Quick Guide
- Matplotlib - Useful Resources
- Matplotlib - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Matplotlib - Mathematical Expressions
You can use a subset TeXmarkup in any Matplotlib text string by placing it inside a pair of dollar signs ($).
# math text plt.title(r'$\alpha > \beta$')
To make subscripts and superscripts, use the '_' and '^' symbols −
r'$\alpha_i> \beta_i$' import numpy as np import matplotlib.pyplot as plt t = np.arange(0.0, 2.0, 0.01) s = np.sin(2*np.pi*t) plt.plot(t,s) plt.title(r'$\alpha_i> \beta_i$', fontsize=20) plt.text(0.6, 0.6, r'$\mathcal{A}\mathrm{sin}(2 \omega t)$', fontsize = 20) plt.text(0.1, -0.5, r'$\sqrt{2}$', fontsize=10) plt.xlabel('time (s)') plt.ylabel('volts (mV)') plt.show()
The above line of code will generate the following output −

Advertisements