0Pricing
Data Science Academy · บทเรียน

ความสัมพันธ์: scatter และ line

สร้างกราฟตัวแปรสองตัวร่วมกัน

ความสัมพันธ์: scatter และ line เป็นบทเรียน Data Science Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Data Science Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Data Science Academy มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

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. 🔗

คำถามที่พบบ่อย

บทเรียน “ความสัมพันธ์: scatter และ line” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “ความสัมพันธ์: scatter และ line” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Data Science Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Data Science Academy มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “ความสัมพันธ์: scatter และ line”

สร้างกราฟตัวแปรสองตัวร่วมกัน คุณปฏิบัติ Data Science Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Data Science Academy หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Data Science Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน

บทเรียน “ความสัมพันธ์: scatter และ line” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Data Science Academy นี้ได้ไหม

ได้ บทเรียน Data Science Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. เหตุใดจึงใช้ seaborn แทน matplotlib แบบพื้นฐาน
  2. การแจกแจง: hist, kde และ box
  3. ความสัมพันธ์: scatter และ line
  4. แฟกเซ็ต สี และรูปแบบ
← กลับไปที่ Data Science Academy