Steuerung des Stils von Text und Beschriftungen mit einem Wörterbuch#

Dieses Beispiel zeigt, wie Parameter über viele Textobjekte und Beschriftungen hinweg geteilt werden können, indem ein Wörterbuch mit Optionen erstellt wird, das an mehrere Funktionen übergeben wird.

Damped exponential decay
import matplotlib.pyplot as plt
import numpy as np

font = {'family': 'serif',
        'color':  'darkred',
        'weight': 'normal',
        'size': 16,
        }

x = np.linspace(0.0, 5.0, 100)
y = np.cos(2*np.pi*x) * np.exp(-x)

plt.plot(x, y, 'k')
plt.title('Damped exponential decay', fontdict=font)
plt.text(2, 0.65, r'$\cos(2 \pi t) \exp(-t)$', fontdict=font)
plt.xlabel('time (s)', fontdict=font)
plt.ylabel('voltage (mV)', fontdict=font)

# Tweak spacing to prevent clipping of ylabel
plt.subplots_adjust(left=0.15)
plt.show()

Gesamtlaufzeit des Skripts: (0 Minuten 1,391 Sekunden)

Galerie generiert von Sphinx-Gallery