matplotlib text on plot code example
Example 1: add text to plot python
import matplotlib.pyplot as plt
w = 4
h = 3
d = 70
plt.figure(figsize=(w, h), dpi=d)
x = [1, 2, 4]
x_pos = 0.5
y_pos = 3
plt.text(x_pos, y_pos, "text on plot")
plt.plot(x)
plt.savefig("out.png")Outputout.png
Example 2: add caption to plot python
txt="I need the caption to be present a little below X-axis"
plt.figtext(0.5, 0.01, txt, wrap=True, horizontalalignment='center', fontsize=12)