Ich möchte eine Matplotlib-Figur mit einer x-Achsenbeschriftung erstellen, die in Arial-Schriftart ist und ein Wort kursiv geschrieben hat.Matplotlib xlabel in Arial mit einem Wort kursiv geschrieben
Ich kann Figuren mit x-Achsen-Etiketten in Latex-Schriftart mit einem Wort kursiv erstellen; Ich kann auch Zahlen mit x-Achsen-Beschriftungen in Arial erstellen, solange entweder die gesamte Beschriftung kursiv oder die gesamte Beschriftung normal ist. aber ich kann keinen Teil des xlabel in Arial kursiv und den anderen Teil in arial normal bekommen.
Ich bin meistens Permutationen des folgenden Code versuchen:
from matplotlib import pyplot as plt
import numpy as n
import matplotlib
from matplotlib.font_manager import FontProperties
font = {'family' : 'Arial',
'weight' : 'medium',
'size' : 20,
'style' : 'normal'}
font0 = {'family' : 'Arial',
'weight' : 'medium',
'size' : 20,
'style' : 'italic'}
matplotlib.rcParams['mathtext.fontset'] = 'custom'
matplotlib.rcParams['mathtext.rm'] = 'Arial'
matplotlib.rcParams['mathtext.it'] = 'Arial'
matplotlib.rc('font', **font)
#matplotlib.rc('font', **font0)
matplotlib.rc('text', usetex=False)
plt.figure(); plt.plot(n.linspace(0,3,10), n.linspace(0,3,10))
plt.xlabel(r'$\mathit{italics}$ - rest normal')
Fantastic !! Das funktioniert, und die Idee mit dem Font Manager ist großartig - danke! – mzzx