PyPlot legend font

Hello everyone. I need to change the font legend in PyPlot. I have searched and can’t find a natural way to do it.
Font.legend.family = monospace.

PyPlot shares the matplotlib interface. Therefore, it is always possible to refer to the matplotlib documentation:
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.legend.html (see the “prop” option description)
https://matplotlib.org/stable/api/font_manager_api.html#matplotlib.font_manager.FontProperties (for possible font options)

The MWE will be the following:

using PyPlot

x = range(-4.0, 4.0, length=100)
y = @. exp(-x^2)

plot(x, y, label="Gaussian")

font = matplotlib.font_manager.FontProperties(
    family = "monospace",
    weight = "bold",
    style = "italic",
    size = 16,
)

legend(prop=font)

Figure_1

1 Like

Very good, thank you.