I am using the following to plot a horizontal line in matplotlib:
axScatter.axhline(y=0.285987, xmin=-1.5, xmax=0.491, color='black', linestyle=':')
However, it is just ever so slightly out:
I'd rather have a function where y = 0.285987 between the x-range: -1.5 and ~0.72. Does anyone know how to plot a line without using axhline
?
axhline
xmin and xmax are to given in the axes coordinates (so that 0.5 is the middle of the axes). If you want to have a exact line in data coordinates you could just use plot:
x = [-1.5, 0.72]
y = [0.285987, 0.285987]
ax.plot(x, y)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.