[Python] How to style size and color of matplotlib suptitle?

Discussão em 'Python' iniciado por Stack, Maio 15, 2025.

  1. Stack

    Stack Membro Participativo

    This should be straightforward: I want to style the matplotlib suptitle.

    Documentation says that fontproperties is a dict of font properties that can be supplied as a parameter.

    So:

    import matplotlib.pyplot as plt
    import matplotlib as mpl

    fig, ax = plt.subplots()
    ax.set_xlim(0, 1)
    fdct = {'color': 'r', 'fontsize': 32}
    # Generates error
    fig.suptitle('A title', fontproperties=fdct)
    # Works
    fig.suptitle('A title', fontsize=32)


    The first command generates

    TypeError: FontProperties.__init__() got an unexpected keyword argument 'color'

    But why? I would like to style suptitle with a dict of font properties, like I do for other instances of Text.

    Continue reading...

Compartilhe esta Página