I'm trying to plot some data with Matplotlib (Python library) and to add an horizontal line, that would not cover the full axis range but start around the middle and finish on the right axis.
I am using:
Just draw a line with
import numpy as np import matplotlib.pyplot as plt x = np.linspace(0.2,10,100) fig, ax = plt.subplots() ax.plot(x, 1/x) ax.plot(x, np.log(x)) ax.set_aspect('equal') ax.grid(True, which='both') y = 1.25 xmin = 2 xmax = ax.get_xlim() ax.plot([xmin, xmax], [y, y], color='k')
which gives me: