

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 – 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 Questions & Answers
- HTML5 Canvas Degree Symbol
- 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?
- Plot multiple time-series DataFrames into a single plot using Pandas (Matplotlib)
- How do I print a Celsius symbol with Matplotlib?
- Insert Euro and Dollar symbol to a column in MySQL?
- 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 circle in Matplotlib?
- How to plot a bar chart for a list in Python matplotlib?
- How to surface plot/3D plot from a dataframe (Matplotlib)?
- How do I insert a JPEG image into a Python Tkinter window?
Advertisements