I am trying to figure out how to determine the slope trend from best fit lines that have points. Basically, once I have the trend in the slope, I want to plot multiple other lines with that trend in the same plot. For example:
This plot is basically what I want to do, but I am not sure how to do it. As you can see, it has several best fit lines with points that have slopes and intersect at x = 6. After those lines, it has several lines that are based on the trend from the other slopes. I am assuming that using this code I can do something similar, but I am unsure how to manipulate the code to do what I want.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# simulate some artificial data
# =====================================
df = pd.DataFrame( { 'Age' : np.random.rand(25) * 160 } )
df['Length'] = df['Age'] * 0.88 + np.random.rand(25) * 5000
# plot those data points
# ==============================
fig, ax = plt.subplots()
ax.scatter(df['Length'], df['Age'])
# Now add on a line with a fixed slope of 0.03
slope = 0.03
# A line with a fixed slope can intercept the axis
# anywhere so we're going to have it go through 0,0
x_0 = 0
y_0 = 0
# And we'll have the line stop at x = 5000
x_1 = 5000
y_1 = slope (x_1 - x_0) + y_0
# Draw these two points with big triangles to make it clear
# where they lie
ax.scatter([x_0, x_1], [y_0, y_1], marker='^', s=150, c='r')
# And now connect them
ax.plot([x_0, x_1], [y_0, y_1], c='r')
plt.show()