简体   繁体   中英

How to add text to matplotlib plot from a figure object?

My code contains the following lines:

from matplotlib.figure import Figure

figure = Figure(figsize=(10, 5), dpi=dpi)

How can I add text to this

Texts can be added from a axis object. So you may try this:

from matplotlib.figure import Figure
figure = Figure(figsize=(10, 5), dpi=dpi)
ax = figure.add_axes((0.05, 0.05, 0.9, 0.9))
ax.text(0.5, 0.5, 'Text', ha='center')

More examples can see the document , and details of parameters here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM