Question: my code looks something like this: 

```
%matplotlib inline 
import matplotlib.pyplot as plt
import numpy as np

for x in np.arange(0,100,5):

plt.scatter(x, x**2, c="blue", marker="o",s=1)

plt.legend()
plt.xlabel("$x$", fontsize=16)
plt.ylabel("$f(x)$", fontsize=16)
plt.show()

```

which gives me the attached picture:
![plot](https://i.stack.imgur.com/U3UTB.jpg)

How can I connect the points with lines, or even more preferably, a smooth curve?

Thanks for your help in advance!

Answer: 
You can use [`plot`](https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.plot) to create a smooth line rather than [`scatter`](https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.scatter.html), which plots the individual points. Also, you do not need to do any loops here, matplotlib handles the plotting of arrays.

```
x = np.arange(0, 100, 5)

plt.plot(x, x ** 2, c="blue")

plt.xlabel("$x$", fontsize=16)
plt.ylabel("$f(x)$", fontsize=16)
plt.show()

```

Which gives:

[![enter image description here](https://i.stack.imgur.com/raAjv.png)](https://i.stack.imgur.com/raAjv.png)

**Edit**

I don't think there is a way to join the points directly using scatter. You could do 

```
plt.scatter(x, x ** 2, c="blue",s=1)
plt.plot(x, x ** 2, c="blue")

```

which is essentially

```
plt.plot(x, x**2, color="blue", marker="o")

```

which is the same as @ImportanceOfBeingErnest's answer
A `scatter` plot shows individual points of (potentially) different size and color. It seems that in this case, you want to have line `plot`.  

Second, there is no reason to loop over the individual points from the array. Instead you want to supply the complete array to the plotting function.

```
import matplotlib.pyplot as plt
import numpy as np

x = np.arange(0,100,5)

plt.plot(x, x**2, color="blue", marker="o",ms=5, label="label")

plt.legend()
plt.xlabel("$x$", fontsize=16)
plt.ylabel("$f(x)$", fontsize=16)
plt.show()

```

[![enter image description here](https://i.stack.imgur.com/ebb9n.png)](https://i.stack.imgur.com/ebb9n.png)