Matplotlib: Temperatur in Grad Celsius (°C) formatieren
Basierend auf unserem vorherigen Beitrag zu Matplotlib custom SI-prefix unit tick formatters ist dies ein einfacher Schnipsel, den du verwenden kannst, um die Y-Achse deiner Matplotlib-Plots zu formatieren:
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