In [1]:
%load_ext watermark
%watermark -a 'Hideki Tanaka' -u -d -v -p matplotlib,numpy
In [2]:
%matplotlib inline
In [3]:
import matplotlib.pyplot as plt
import numpy as np
In [4]:
num_lines = 10
x = np.linspace(0, 2*np.pi)
offsets = np.linspace(0, 2*np.pi, num_lines, endpoint=False)
yy = [np.sin(x+phi) for phi in offsets]
labels = range(1, num_lines+1)
In [5]:
with plt.style.context('../styles/saiplot.mplstyle'):
fig, ax = plt.subplots()
for y, label in zip(yy, labels):
ax.plot(x, y, label=label)
ax.set_xlim(0, 2*np.pi)
ax.set_xticks([0, np.pi/2, np.pi, np.pi*3/2, 2*np.pi])
ax.set_xticklabels(['0', '$\pi/2$', '$\pi$', '$3/2\pi$', '2$\pi$'])
ax.set_ylim(-1.2, 1.2)
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.legend(loc=1, ncol=1, bbox_to_anchor=(1.17, 0.95))
plt.show()
In [6]:
fig.savefig('../images/mpl_saiplot.png', dpi=80)