VOOZH about

URL: https://www.geeksforgeeks.org/python/how-to-connect-scatterplot-points-with-line-in-matplotlib/

⇱ How to Connect Scatterplot Points With Line in Matplotlib? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Connect Scatterplot Points With Line in Matplotlib?

Last Updated : 23 Jul, 2025

Prerequisite: Scatterplot using Seaborn in Python

Scatterplot can be used with several semantic groupings which can help to understand well in a graph. They can plot two-dimensional graphics that can be enhanced by mapping up to three additional variables while using the semantics of hue, size, and style parameters. And matplotlib is very efficient for making 2D plots from data in arrays. In this article, we are going to see how to connect scatter plot points with lines in matplotlib.

Approach:

  • Import module.
  • Determined X and Y coordinate for plot scatter plot points.
  • Plot scatterplot.
  • Plot matplotlib.pyplot with the same X and Y coordinate.

Below is the implementation:

Example 1:

Output:

👁 Image

Example 2:

Output:

👁 Image

Example 3: 

We can also connect scatter plot points with lines without using seaborn.scatterplot. We will use only pyplot to connect the scatter points with lines.

Output:

👁 Image
Comment
Article Tags: