Subplot with text only

Viewed 1844

I have a figure composed of many subplot bars. I would like one of my subplots to be simply a kind of textbox that will list all the parameters I used in all the plots around.

How can I do this in python?

Is there something like plt.textbox("my text"), that I can make appear exactly like any plot on a figure.

I don't want text inside a figure, I want a subplot that is only composed of text.

1 Answers

You can make a subplot empty with the set_axis_off() method and then add your text with the text() method, whose first two arguments specify the coordinates of the lower left corner of the text box, within the default 0-1 coordinate system of the subplot.

import matplotlib.pyplot as plt

fig, ax = plt.subplots(2, 2)
x = [1, 2]
y = [1, 2]

ax[0, 0].plot(x, y)
ax[0, 1].plot(x, y)
ax[1, 0].plot(x, y)

ax[1, 1].set_axis_off()
ax[1, 1].text(0.5, 0.5, 'my text');

textplot demonstration

Related