I try to make a linear trendline (with a corresponding equation) with the following code, however, using what I have below creates a line that goes through each point, rather than creating a average. The function 'plt.plot(x1, y1,'r-')' worked in producing a linear trendline for a line graph I had constructed previously. Why would it not work for a scatter graph?
In addition to this, I was trying to eliminate the two -1 y-values, I have eliminated some x-values by defining x1 as shown bellow.
x = rainfall_container[0]
y = ndvi_container[0]
fig = plt.figure()
x1 = x[x > 0.0]
y1 = y[x > 0.0]
plt.scatter(x1, y1)
plt.plot(x1, y1,'r-')