scatter plot and line in python
<p>I have a question about how to place scatter plot and line into one graph correctly.</p>

<p>Here is the code:</p>

<pre><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()
</code></pre>

<p><a href="https://i.stack.imgur.com/cuk9R.png" rel="nofollow">enter image description here</a></p>

<p>As it can be seen scatter plot reflecting is not correct(it displays as lines)</p>

<p>Thank you!</p>

<p>Assuming you want the variable <code>data</code> to be displayed in the scatter plot,</p>

<pre><code>ax.scatter(data.Weight, data.Height , color = 'red')
</code></pre>

python numpy matplotlib plot