
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Superscript in Python plots
To put some superscript in Python, we can take the following steps −
Create points for a and f using numpy.
Plot f = ma curve using the plot() method, with label f=ma.
Add title for the plot with superscript, i.e., kgms-2.
Add xlabel for the plot with superscript, i.e., ms-2.
Add ylabel for the plot with superscript, i.e., kg.
To place the legend, use legend() method.
To display the figure, use the show() method.
Example
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True a = np.linspace(1, 10, 100) m = 20 f = m*a plt.plot(a, f, c="red", lw=5, label="f=ma") plt.title("Force $\mathregular{kgms^{-2}}$") plt.xlabel("Acceleration $\mathregular{ms^{-2}}$") plt.ylabel("Acceleration $\mathregular{kg}$") plt.legend() plt.show()
Output
- Related Articles
- Categorical plots in Python Data Visualization
- Contour Plots using Plotly in Python
- Demonstrate the working of violin plots in Python?
- Categorical and distribution plots in Python Data Visualization
- HTML DOM Superscript Object
- Explain about the anatomy of Matplotlib plots in Python?
- How to mark text superscript in HTML?
- Subscript and SuperScript a string in Android?
- How to put text outside Python plots?
- Annotate bars with values on Pandas bar plots in Python
- How can Pygal be used to generate line plots in Python?
- How can Pygal be used to generate box plots in Python?
- How can Pygal be used to generate dot plots in Python?
- How can Pygal be used to generate Funnel plots in Python?
- How can Pygal be used to generate Gauge plots in Python?

Advertisements