0Pricing
Data Science Academy · Lesson

Relationships: scatter and line

Plotting two variables together.

Relationships: scatter and line is a free Data Science Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Data Science Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

From One Column to Two

Distributions look at a single column. Now you ask how two columns move together, which is the heart of finding a relationship.

The Scatter Plot

A scatter plot places one dot per row, using two columns as x and y. The cloud of dots reveals how the variables connect.

sns.scatterplot(data=df, x="hours", y="score")

Read the Pattern

Dots sloping up mean a positive link, sloping down means negative, and a shapeless blob means little correlation between them.

Add a Third Dimension With hue

Color the dots by a category using hue. Now one plot shows the relationship split across each group at the same time.

sns.scatterplot(data=df, x="hours", y="score", hue="grade")

Size Encodes a Fourth Variable

Map a column to dot size to pack in even more. Bigger dots can mean larger sales, population, or any numeric measure.

sns.scatterplot(data=df, x="hours", y="score", size="effort")

The Line Plot

When x is ordered, like dates or steps, a line plot connects the points to show how a value changes over that sequence.

sns.lineplot(data=df, x="month", y="revenue")

Scatter vs Line

Use a scatter for unordered pairs and a line when the x axis flows in order. Picking the right one keeps the trend honest.

Lines Aggregate Automatically

If several rows share an x value, seaborn averages their y and draws a shaded confidence band around the line for you.

Multiple Lines With hue

Add hue to a line plot and each category becomes its own colored line. Comparing trends across groups takes just one extra word.

sns.lineplot(data=df, x="month", y="revenue", hue="region")

Add a Trend Line With regplot

Want the best-fit line drawn through a scatter? regplot overlays a regression line so the direction is impossible to miss.

sns.regplot(data=df, x="hours", y="score")

Correlation Is Not Causation

A clear upward cloud shows two things rise together, not that one causes the other. Always pair a plot with judgment.

Quick Check

Your x axis is ordered by month and you want to show change over time.

Recap: Show How Two Things Connect

You can now reveal relationships with scatter for pairs and lines for ordered trends, and add hue or size to layer in more. 🔗

Frequently asked questions

Is the “Relationships: scatter and line” lesson free?

Yes — the full text of “Relationships: scatter and line” is free to read here on the web, and the Data Science Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Data Science Academy course, upgrade to CoddyKit PRO.

What will I learn in “Relationships: scatter and line”?

Plotting two variables together. You practise Data Science Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Data Science Academy?

No prior experience is required. Data Science Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Relationships: scatter and line” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Data Science Academy lesson?

Yes. Every Data Science Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Why seaborn Over Raw matplotlib
  2. Distributions: hist, kde, box
  3. Relationships: scatter and line
  4. Facets, Hue, and Style
← Back to Data Science Academy