Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add footnote under the x-axis using matplotlib

Tags:

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? Thanks!

like image 639
Flake Avatar asked Oct 27 '11 14:10

Flake


People also ask

How do you add footnotes in Python?

[^@#$%]: A footnote on the label: "@#$%". A footnote label must start with a caret ^ and may contain any inline text (including spaces) between a set of square brackets [] . Only the first caret has any special meaning. A footnote content must start with the label followed by a colon and at least one space.

How do you put text under a plot in Python?

Add text under plot matplotlib We use the figtext() method to add text in the figure area and we set the horizontal and vertical alignment at the center. In this above example, we add the text under the plot by using the fig. text() method and we pass the argument x = 0.5 and y=0.01.

How do I add figure captions in Matplotlib?

To add caption to the figure, use text() method. Adjust the padding between and around the subplots. To display the figure, use show() method.

How do I fill in below a line in Matplotlib?

To fill the area under the curve, put x and y with ste="pre", using fill_between() method. Plot (x, y1) and (x, y2) lines using plot() method with drawstyle="steps" method. To display the figure, use show() method.


2 Answers

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

like image 87
ev-br Avatar answered Oct 20 '22 09:10

ev-br


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

like image 23
Wojciech Moszczyński Avatar answered Oct 20 '22 09:10

Wojciech Moszczyński