Ich kann keine Bilder in iPython von Matplotlib angezeigt werden, ein Bild erscheint für einen Bruchteil einer Sekunde in einem Popup-Fenster statt inline und schließt dann sofort. In der iPython-Konsole, die sich in Spyder befindet, wird nichts angezeigt.Plots funktionieren nicht in Matplotlib
from statistics import mean
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.pyplot import style
style.use('fivethirtyeight')
xs = np.array([1,2,3,4,5,6], dtype=np.float64)
ys = np.array([5,4,6,5,6,7], dtype=np.float64)
def best_fit_slop_and_intercept (xs,ys):
m = (((mean(xs)*mean(ys))-mean(xs*ys))/
((mean(xs)**2)-mean(xs**2)))
b = mean(ys)-m*mean(xs)
return m,b
m,b = best_fit_slop_and_intercept(xs,ys)
print (m,b)
regression_line = [m*x + b for x in xs ]
print (regression_line)
predict_x = 9
predict_y = predict_x*m + b
plt.scatter(predict_x,predict_y, color = 'g')
plt.scatter(xs,ys)
plt.plot(xs, regression_line)
plt.show()
habe ich versucht, dies in ipython (ohne Spyder) auszuführen? Ich habe keine Spyder aber dieser Code läuft gut für mich. (öffnet ein Fenster und bleibt, bis ich gehe) – putonspectacles