matplotlib - Change text style midway through a string -
i'm trying figure out how change font style mid way through string. far best way i've come mess horizontalalignment
parameter:
self.ax.text(0.7, 0.1, 'bold', style='italic', weight='bold', horizontalalignment='right', transform=self.ax.transaxes, size=24) self.ax.text(0.7, 0.1, ' italic', style='italic', horizontalalignment='left', transform=self.ax.transaxes, size=24)
but seems ugly, , more importantly it's not robust: suppose want 3 styles, what? isn't there way change style mid way?
one option use latex this:
fig, ax = subplots() x = linspace(0, 2 * pi, 1000) y = sin(x) ax.plot(x, y) rc('text', usetex=true) ax.annotate(r'$\sin$ wavez \textbf{n}\textit{e}ato', (3, 0.1), size=15)
Comments
Post a Comment