2016-10-16 6 views
0

Ich habe eine Frage darüber, wie Streudiagramm und Linie in einem Diagramm richtig platziert werden.Streudiagramm und Linie in Python

Hier ist der Code:

import numpy as np 
import matplotlib.pyplot as plt 

t= np.linspace(60, 180,100) 
ax= plt.subplot() 
ax.plot(data.Weight, data.Height , color = 'red') 
ax.plot(t, 60+ 0.05*t, label=r"$Height = 60+ 0.05*Weight$") 
ax.plot(t, 50+ 0.16*t, label=r"$Height = 50+ 0.16*Weight$") 
ax.set_xlabel(r'$Weight$', fontsize=12) 
ax.set_ylabel(r'$Height$', fontsize=12) 
ax.set_title('Dependence') 

plt.show() 

enter image description here

Wie Streudiagramm zu sehen ist reflektieren nicht korrekt ist (es zeigt als Linien)

Thank you!

Antwort

-1

Vorausgesetzt, dass Sie die Variable data in dem Streudiagramm angezeigt werden sollen,

ax.scatter(data.Weight, data.Height , color = 'red') 
0

zu zerstreuen data.Weight gegen data.Height:

ax.plot(data.Weight, data.Height , 'o', markerfacecolor = 'red') 
Verwandte Themen