I want to make 2 different linear regressions for 2 diferent graphs (on the same figure). I have a problem with the y1_pred because it does not go for all the y axis where are scatters. model1 = LinearRegression().fit(x, y) r_sq1 = model1.score(x, y) intercept1 = model1.intercept_ slope1 = model1.coef_ print(r_sq1) y1_pred = intercept1 + slope1 * x model2 = LinearRegression().fit(x2, y2) r_sq2 = model2.score(x2, y2) intercept2 = model2.intercept_ slope2 = model2.coef_ print(r_sq2) y2_pred = intercept2 + slope2 * x2 axs[0].scatter(x, y, marker='o', color='aqua', label='1980-2000', edgecolors = 'black', linewidths = 1, s=500, zorder=4) axs[1].scatter(x2, y2, marker='o', color='magenta', label='2000-2024', edgecolors = 'black', linewidths = 1, s=500, zorder=4) axs[0].plot(x2, y2_pred, color='red', linewidth=4) axs[1].plot(x, y1_pred, color='red', linewidth=4) enter image description here enter image description here Continue reading...