I am trying to plot a linear regression line for the following x and y data. It always can show up the scatter plot of (x,y), but it can never draw me the regression line!
import numpy as np
from PIL import Image
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
# this part is about the calculation of x and y. It is correct. The problem occurs in the following part to draw the linear regression line!
x = [x_julia, x_mandelbrot]
y = [y_julia, y_mandelbrot]
plot_x_byScales([x_julia, x_mandelbrot], ['julia','mandelbrot'], ylabel="A")
plot_y_byScales([y_julia, y_mandelbrot], ['julia','mandelbrot'], ylabel="B")
plt.plot(y_julia, x_julia, 'o', color='red',label='julia')
plt.plot(y_mandelbrot, x_mandelbrot, 'o', color='blue',label='mandelbrot')
plt.xlabel('B',fontsize=16)
plt.ylabel('A',fontsize=16)
X = x_julia
Y = y_julia
plt.plot(X, Y, 'o')
m, b = np.polyfit(X, Y, 1)
m = slope, b=intercept
plt.plot(X, m*X + b)
please help me to figure out how to plot this regression line!