How to change legend patches after plotting?
06:22 30 Jun 2025

I have a function that is supposed to enlarge all labels in a figure to make it ready for export. However I fail to enlarge the legend properly:

import matplotlib.pyplot as plt

def enlarge_legend(ax, fontSize = 25):
    for text in ax.get_legend().get_texts():
        text.set_fontsize(fontSize)


fig, ax = plt.subplots()
ax.scatter(
        [1,2,3],
        [2,3,1],
        label = "auto"
        )
ax.legend()
enlarge_legend(ax)

result:
enter image description here

I would like the circle patch to be bigger as well but both ax.get_legend().get_patches() and ax.get_legend().get_lines() return empty lists. Any idea how to do it?

python matplotlib legend