'Multiple Fonts In A Matplotlib Title

I am currently leveraging Matplotlib to generate a variety of graphics and want to use a series of custom fonts. I am specifically using the Milliard font package in OpenType format. Consider the following code for a skeleton plot with this specific title definition:

from matplotlib import font_manager as fm, rcParams
import matplotlib.pyplot as plt

fig, ax = plt.subplots()
fpath = os.path.join(rcParams["datapath"], "fonts/otf/Milliard Medium.otf")
prop = fm.FontProperties(fname=fpath)
fname = "Milliard Medium.otf"
plt.title("This Is The Top Title Line".format(fname) + "\n" + "This Is The Bottom Title Line", loc='left', fontsize=15, fontproperties=prop)

The skeleton example plot looks as follows:

enter image description here

I've mapped the desired font using the FontManager class, which is passed into the title string font properties. How would I apply two separate font definitions (say "Milliard Medium" & "Milliard Light") in one title string split by a new line character?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source