
- 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
Matplotlib – How to insert a degree symbol into a Python plot?
To insert a degree symbol into a plot, we can use LaTeX representation.
Steps
- Create data points for pV, nR and T using numpy.
- Plot pV and T using plot() method.
- Set xlabel for pV using xlabel() method.
- Set the label for temperature with degree symbol using ylabel() method.
- To display the figure, use show() method.
Example
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True pV = np.array([3, 5, 1, 7, 10, 9, 4, 2]) nR = np.array([31, 15, 11, 51, 12, 71, 41, 13]) T = np.divide(pV, nR) plt.plot(pV, T, c="red") plt.xlabel("Pressure x Volume") plt.ylabel("Temperature ($^\circ$C)") plt.show()
Output
- Related Articles
- How to a plot stem plot in Matplotlib Python?
- How to insert a small image on the corner of a plot with Matplotlib?
- How to plot a density map in Python Matplotlib?
- How to plot a multivariate function in Python Matplotlib?
- HTML5 Canvas Degree Symbol
- How to plot a layered image in Matplotlib in Python?
- How to save a plot in Seaborn with Python (Matplotlib)?
- How to plot a phase spectrum in Matplotlib in Python?
- How to plot a bar chart for a list in Python matplotlib?
- Plot multiple time-series DataFrames into a single plot using Pandas (Matplotlib)
- How to zoom a portion of an image and insert in the same plot in Matplotlib?
- How to plot a function defined with def in Python? (Matplotlib)
- How to plot a 3D density map in Python with Matplotlib?
- How to plot a 2D matrix in Python with colorbar Matplotlib?
- How to merge two existing Matplotlib plots into one plot?

Advertisements