fig, ax = plt.subplots(figsize=(4, 2.5)) x = np.arange(0, 13, 0.2) y = np.sin(x) lines = ax.plot(x, y, '-', label='example') lines[0].set_data([x, np.cos(x)])