Relazioni: scatter e linee
Rappresentare insieme due variabili.
Relazioni: scatter e linee è una lezione Data Science Academy gratuita su CoddyKit. Questa è la lezione 3 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Data Science Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Data Science Academy include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
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. 🔗
Domande Frequenti
La lezione «Relazioni: scatter e linee» è gratuita?
Sì — il testo completo di «Relazioni: scatter e linee» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Data Science Academy, passa a CoddyKit PRO. Il corso Data Science Academy include 4 lezioni in totale.
Cosa imparerò in «Relazioni: scatter e linee»?
Rappresentare insieme due variabili. Eserciti Data Science Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare Data Science Academy?
Non è richiesta alcuna esperienza precedente. Data Science Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 3 di 4.
Quanto tempo richiede la lezione «Relazioni: scatter e linee»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione Data Science Academy?
Sì. Ogni lezione Data Science Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Perché seaborn invece di matplotlib puro
- Distribuzioni: hist, kde e box
- Relazioni: scatter e linee
- Facet, hue e style