# Nakafa Learning Content

> For AI agents: use [llms.txt](https://nakafa.com/llms.txt) for the site index. Markdown versions are available by appending `.md` to content URLs or sending `Accept: text/markdown`.

URL: https://nakafa.com/en/subjects/mathematics/statistics-regression/scatter-diagram
Source: https://raw.githubusercontent.com/nakafaai/nakafa.com/refs/heads/main/packages/contents/material/lesson/mathematics/statistics-regression/scatter-diagram/en.mdx

Create scatter plots to visualize relationships between two variables. Identify positive, negative, and no correlation patterns through data point analysis.

---

## What Is a Scatter Diagram?

A Scatter Diagram is like a map that shows the relationship between two types of data. For example, we might want to see the relationship between study time ($$x$$-axis) and exam scores ($$y$$-axis).

Visible text: A Scatter Diagram is like a map that shows the relationship between two types of data. For example, we might want to see the relationship between study time (-axis) and exam scores (-axis).

Each point on the diagram represents one pair of data (e.g., one student's data). By looking at the pattern of the points, we can understand their relationship.

### When Should a Scatter Diagram Be Used?

A Scatter Diagram is most suitable when we want to:

- See if there is a **relationship (correlation)** between **two numerical variables (numbers)**. (Example: the relationship between height and weight, or study time and scores.)
- See the **pattern** of that relationship (whether it's positive, negative, or no pattern).

This differs from other diagrams:

- **Bar Chart:** Good for comparing quantities or values between **categories** (e.g., number of students per class).
- **Line Chart:** Good for seeing **trends** in data over **time** or a specific sequence (e.g., daily temperature changes).
- **Pie Chart:** Good for showing **proportions** or parts of a whole (e.g., percentage of favorite fruit types).

So, if your main focus is **seeing the relationship between two sets of numbers**, a scatter diagram is the right choice!

## Scatter Diagram Examples and Correlation Patterns

Let's look at some examples of scatter diagrams with different patterns:

### Positive Correlation

If the points tend to rise from the bottom left to the top right, it means there is a **positive correlation**. As the value of $$X$$ increases, the value of $$Y$$ also tends to increase.

Visible text: If the points tend to rise from the bottom left to the top right, it means there is a **positive correlation**. As the value of increases, the value of also tends to increase.

Component: ScatterDiagram
Props:
- title: Relationship Between Study Time (Hours) and Exam Scores
- description: Example of positive correlation: The longer the study time, the higher the exam scores tend to be, although not always perfectly.
- xAxisLabel: Study Time (Hours)
- yAxisLabel: Exam Score
- datasets: [
{
name: "Student",
color: "var(--chart-1)",
points: [
{ x: 1, y: 60 },
{ x: 1.5, y: 68 },
{ x: 2, y: 65 },
{ x: 2.5, y: 75 },
{ x: 3, y: 72 },
{ x: 3.5, y: 80 },
{ x: 4, y: 85 },
{ x: 4, y: 82 },
{ x: 4.5, y: 90 },
{ x: 5, y: 88 },
{ x: 5.5, y: 95 },
{ x: 6, y: 92 },
],
},
]

### Negative Correlation

If the points tend to fall from the top left to the bottom right, it means there is a **negative correlation**. As the value of $$X$$ increases, the value of $$Y$$ tends to decrease.

Visible text: If the points tend to fall from the top left to the bottom right, it means there is a **negative correlation**. As the value of increases, the value of tends to decrease.

Component: ScatterDiagram
Props:
- title: Relationship Between Car Age (Years) and Selling Price (Tens of Millions)
- description: Example of negative correlation: The older the car, the lower its selling price tends to be.
- xAxisLabel: Car Age (Years)
- yAxisLabel: Selling Price (Tens of Millions Rupiah)
- datasets: [
{
name: "Used Car",
color: "var(--chart-2)",
points: [
{ x: 1, y: 25 },
{ x: 2, y: 22 },
{ x: 2, y: 23 },
{ x: 3, y: 20 },
{ x: 4, y: 18 },
{ x: 4, y: 19 },
{ x: 5, y: 15 },
{ x: 6, y: 14 },
{ x: 7, y: 12 },
{ x: 8, y: 10 },
],
},
]

### No Correlation with Two Groups

If the points are scattered randomly without a clear pattern, it means there is **no correlation** or the correlation is very weak. We can also display different groups in one diagram.

Component: ScatterDiagram
Props:
- title: Relationship Between Height ($$\text{cm}$$) and $$100 \text{ m}$$ Run Time (seconds) for Two Schools
  Visible text: Relationship Between Height () and Run Time (seconds) for Two Schools
- description: Example of no correlation between height and running speed, with data from two different schools.
- xAxisLabel: Height (cm)
- yAxisLabel: Sprint Run Time (seconds)
- xAxisDomain: min-max
- datasets: [
{
name: "School A",
color: "var(--chart-3)",
points: [
{ x: 165, y: 13.5 },
{ x: 170, y: 13.1 },
{ x: 172, y: 13.8 },
{ x: 175, y: 12.9 },
{ x: 178, y: 13.3 },
{ x: 180, y: 12.8 },
{ x: 182, y: 13.6 },
],
},
{
name: "School B",
color: "var(--chart-5)",
points: [
{ x: 168, y: 13.9 },
{ x: 171, y: 13.0 },
{ x: 174, y: 13.5 },
{ x: 176, y: 13.2 },
{ x: 179, y: 12.7 },
{ x: 181, y: 14.0 },
{ x: 185, y: 13.1 },
],
},
]

So, by looking at the distribution pattern of the points on a scatter diagram, we can get an initial idea of how two variables are related, even for different groups of data.