fig, ax = plt.subplots() ax.axline((0, 4), slope=3., color='C0', label='by slope') ax.set_xlim(0, 1) ax.set_ylim(3, 5) ax.legend()