30

I couldn't find the right function to add a footnote in my plot.

The footnote I want to have is something like an explanation of one item in the legend, but it is too long to put in the legend box. So, I'd like to add a ref number, e.g. [1], to the legend item, and add the footnote in the bottom of the plot, under the x-axis.

Which function should I use?

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
Flake
  • 4,377
  • 6
  • 30
  • 29

2 Answers2

24

You would be just use:

plt.figtext(0.5, 0.01, "one text and next text", ha="center", fontsize=18, bbox={"facecolor":"orange", "alpha":0.5, "pad":5})

enter image description here

Wojciech Moszczyński
  • 2,893
  • 21
  • 27
18

One way would be just use plt.text(x,y,'text')

ev-br
  • 24,968
  • 9
  • 65
  • 78
  • Oh, you are right, I forgot this... I will see if I could add it under the x-axis. Cheers. – Flake Oct 27 '11 at 16:09
  • 48
    `plt.annotate` makes this much easier than `plt.text`. `annotate` lets you work in axis or figure coordinates instead of just data coordinates. It's easy to (for example) put text 20 _points_ below the left side of the x-axis. `plt.annotate('Something', (0,0), (0, -20), xycoords='axes fraction', textcoords='offset points', va='top')` – Joe Kington Oct 27 '11 at 22:02
  • 25
    I use plt.figtext(0.99, 0.01, 'footnote text', horizontalalignment='right') – Mark Graph Dec 14 '13 at 08:55
  • @MarkGraph has a great solution. – Kai Wang Nov 16 '18 at 15:09
  • No OOP interface? – ifly6 Sep 30 '19 at 21:48
  • 1
    @JoeKington This gets cut off. – user76284 Jan 29 '20 at 03:06
  • a solution using the OOP interface would be ideal, seeing as that is what the docs suggest to use – baxx Apr 13 '20 at 01:03