Baseado em nosso post anterior sobre Matplotlib custom SI-prefix unit tick formatters, este é um snippet simples que você pode usar para formatar o eixo Y dos seus plots matplotlib:
celsius_formatter.py
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))
Check out similar posts by category:
Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow