Matplotlib: How to format temperature in degrees Celsius (°C)
Based on our previous post on Matplotlib custom SI-prefix unit tick formatters, this is a simple snippet which you can use to format the Y axis of your matplotlib plots:
import matplotlib.ticker as mtick
from matplotlib import pyplot as plt
def format_celsius(value, pos=None):
return f'{value:.1f} °C'
plt.gca().yaxis.set_major_formatter(mtick.FuncFormatter(format_celsius))