'Plot a smooth line in a scatterplot

I was wondering how I could easily add a smooth line which connect the dots of the same color in R. Can anyone help me?

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source