Skip to content

[Bug]: ax.set_title() ignores size/fontsize when font is a FontProperties object #30797

@JosephBARBIERDARNAL

Description

@JosephBARBIERDARNAL

Bug summary

When using set_title(), the size (or fontsize) argument will be ignored if using a custom font, e.g. a FontProperties object.

Code for reproduction

import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties

# assumes Roboto is installed, but works with any family
font = FontProperties(family="Roboto")
fontsize = 30


def left_chart(ax):
    ax.set_title("hey", size=fontsize, font=font)
    ax.text(x=0.2, y=0.5, s="not", size=fontsize, font=font)


def right_chart(ax):
    ax.set_title("hey", size=fontsize)
    ax.text(x=0.2, y=0.5, s="not", size=fontsize)


fig, axs = plt.subplots(ncols=2)
left_chart(axs[0])
right_chart(axs[1])

Actual outcome

Image

Expected outcome

Image

Additional information

  • I do not observe this behavior with other props (color, etc)
  • My issue mentions set_title() because this is how I found out about this behavior and I couldn't reproduce it with just text(), but the root cause might not come from set_title().

Operating system

OS/X

Matplotlib Version

3.10.7

Matplotlib Backend

module://positron.matplotlib_backend

Python version

3.13.1

Jupyter version

/

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions