import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
xpts = [1, 2, 1.5, 1]
ypts = [1, 1, 2, 1]
plt.plot(xpts, ypts)
plt.text(1.4, 1.4, 'Triangle');
xpts = [1, 2, 1.5, 1]
ypts = [1, 1, 2, 1]
plt.plot(xpts, ypts)
plt.text(1.4, 1.4, 'Triangle', fontsize=20);
xpts = [1, 2, 1.5, 1]
ypts = [1, 1, 2, 1]
plt.plot(xpts, ypts)
plt.text(1.4, 1.4, 'Triangle', fontsize=20, color='r');
xpts = [1, 2, 1.5, 1]
ypts = [1, 1, 2, 1]
plt.plot(xpts, ypts)
plt.text(1.4, 1.4, 'Triangle', fontsize=20, color='r', backgroundcolor='lime');
xpts = [1, 2, 1.5, 1]
ypts = [1, 1, 2, 1]
plt.plot(xpts, ypts)
plt.text(1.4, 1.4, 'Triangle', weight='bold');
xpts = [1, 2, 1.5, 1]
ypts = [1, 1, 2, 1]
plt.plot(xpts, ypts)
plt.text(1.25, 1.2, 'Triangle', weight='bold', color='m', fontsize=32, backgroundcolor='y');
This adds text to a graph, and an arrow pointing from the text to some location. The keyword arguments are:
xpts = [1, 2, 1.5, 1]
ypts = [1, 1, 2, 1]
plt.plot(xpts, ypts)
plt.annotate(xy=(2, 1), xytext=(1.8, 1.1), s='vertex', arrowprops={'arrowstyle':'->'});
xpts = [1, 2, 1.5, 1]
ypts = [1, 1, 2, 1]
plt.plot(xpts, ypts)
plt.annotate(xy=(2, 1), xytext=(1.8, 1.1), s='vertex', arrowprops={'width':1, 'headwidth': 5, 'headlength': 8});