Etichette, titoli e legende
Rendere un grafico davvero leggibile.
Etichette, titoli e legende è una lezione Data Science Academy gratuita su CoddyKit. Questa è la lezione 4 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.
A Chart Must Explain Itself
An unlabeled plot is a riddle. Good labels let a reader understand it in seconds without asking you a single question. 🏷️
Give It a Title
Add a clear headline with plt.title that states the chart message, like Monthly Sales by Region.
plt.title("Monthly Sales by Region")Name the X Axis
Label the horizontal axis with plt.xlabel so readers know what each tick along the bottom represents.
plt.xlabel("Month")Name the Y Axis
Use plt.ylabel to say what the height measures, and include the unit, like Sales in dollars.
plt.ylabel("Sales ($)")Add a Legend
When several lines share a chart, a legend maps each color to its meaning so nobody has to guess.
plt.legend()Legends Need Labels
The legend only works if each series has a label. Pass label= in every plot call, then call legend once.
plt.plot(x, y, label="North")Rotate Crowded Ticks
Long category names overlap and become unreadable. Rotate them upright with xticks and a rotation angle.
plt.xticks(rotation=45)Place the Legend
If the legend covers your data, move it. Pass loc like "upper left" to send it to a clearer corner.
plt.legend(loc="upper left")Tidy the Layout
Labels sometimes spill off the edge. Call plt.tight_layout to nudge everything into the figure neatly.
plt.tight_layout()Order of Calls Matters
Add titles and labels after you draw and before you show. matplotlib applies them to the current active axes.
Save the Finished Chart
Share your work by writing it to a file with savefig, choosing a clear name and a sharp resolution.
plt.savefig("sales.png", dpi=150)Quick Check
Two lines on one chart and nobody knows which is which. What did you forget?
Recap: Polish That Plots Earn
You now add a title, axis labels, and a legend, rotate ticks, and save the result. Your charts finally explain themselves! ✨
Domande Frequenti
La lezione «Etichette, titoli e legende» è gratuita?
Sì — il testo completo di «Etichette, titoli e legende» è 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 «Etichette, titoli e legende»?
Rendere un grafico davvero leggibile. 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 4 di 4.
Quanto tempo richiede la lezione «Etichette, titoli e legende»?
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
- Ordinare per una o più colonne
- Il primo riepilogo con groupby
- Grafici a linee e a barre in matplotlib
- Etichette, titoli e legende