0Pricing
Data Science Academy · Pelajaran

Facet, Hue, dan Style

Membagi grafik berdasarkan kategori

Facet, Hue, dan Style adalah pelajaran Data Science Academy gratis di CoddyKit. Ini adalah pelajaran 4 dari 4. Kamu bisa membaca pelajaran lengkapnya di bawah secara gratis — lalu praktikkan langsung di browser dengan editor kode bawaan dan tutor AI 24/7. Ini adalah bagian dari jalur belajar Data Science Academy, dan progresmu tersinkronisasi di web dan aplikasi CoddyKit. Kursus Data Science Academy mencakup 4 pelajaran total.

Bagian dari pelajaran ini belum diterjemahkan dan ditampilkan dalam bahasa Inggris.

One Chart, Many Slices

Sometimes one plot hides too much. Faceting splits your data into a grid of small charts, one per category, so each group gets its own view.

Encode Groups With hue

The lightest way to compare groups is color. hue maps a category to colors inside a single plot, no extra panels needed.

sns.scatterplot(data=df, x="x", y="y", hue="group")

Split Into Columns

To break groups into separate panels, use a figure-level plot with col. Each category becomes its own side-by-side chart.

sns.relplot(data=df, x="x", y="y", col="group")

Split Into Rows Too

Pair col with row to build a full grid. One variable spreads across columns while another stacks down the rows.

sns.relplot(data=df, x="x", y="y", col="region", row="year")

Figure-Level vs Axes-Level

Faceting needs figure-level functions like relplot, displot, and catplot. The plain plots such as scatterplot live inside a single panel.

Wrap Long Facet Rows

Many categories make an endless row. col_wrap tells seaborn how many panels to allow before starting a new line.

sns.relplot(data=df, x="x", y="y", col="city", col_wrap=3)

Style Encodes Without Color

Beyond color, style maps a category to marker shapes or dashed lines, helping when prints are black and white.

sns.lineplot(data=df, x="x", y="y", style="device")

Pick a Color Palette

Swap the colors with palette. Choose a vivid set for distinct groups or a gradient for values that go from low to high.

sns.scatterplot(data=df, x="x", y="y", hue="group", palette="viridis")

Set the Overall Look

One call restyles every chart at once. set_theme controls the background, gridlines, and default palette for the session.

sns.set_theme(style="darkgrid", palette="muted")

Combine hue and Facets

You can layer them: color within each panel and split panels by another field. Just avoid encoding so much that the message gets lost.

sns.relplot(data=df, x="x", y="y", hue="sex", col="day")

Less Is Often More

Every extra hue, style, and facet adds load for the reader. Aim for the simplest view that still answers the question.

Quick Check

You want each category drawn in its own separate panel.

Recap: Encode, Facet, Style

You now layer information with hue and style, split groups using facets, and theme it all cleanly, while keeping the chart easy to read. 🎨

Pertanyaan yang Sering Diajukan

Apakah pelajaran “Facet, Hue, dan Style” gratis?

Ya — teks lengkap “Facet, Hue, dan Style” gratis dibaca di sini di web. Untuk praktiknya secara interaktif (editor kode bawaan dan tutor AI 24/7) dan buka sisa kursus Data Science Academy, upgrade ke CoddyKit PRO. Kursus Data Science Academy mencakup 4 pelajaran total.

Apa yang akan aku pelajari di “Facet, Hue, dan Style”?

Membagi grafik berdasarkan kategori Kamu berlatih Data Science Academy dengan kode praktik yang langsung kamu jalankan di browser, dan tutor AI 24/7 menjawab pertanyaanmu saat kamu mengerjakan pelajaran ini.

Apakah aku perlu pengalaman untuk memulai Data Science Academy?

Tidak diperlukan pengalaman sebelumnya. Data Science Academy di CoddyKit dirancang untuk pemula hingga pelajar tingkat lanjut, jadi kamu bisa memulai di sini atau dari awal dan belajar sesuai kecepatan kamu sendiri. Ini adalah pelajaran 4 dari 4.

Berapa lama pelajaran “Facet, Hue, dan Style” memakan waktu?

Sebagian besar pelajaran CoddyKit memakan waktu sekitar 5–10 menit. Setiap pelajaran ringkas dan interaktif, jadi kamu membuat kemajuan stabil dan melanjutkan dari tempat kamu tinggalkan di web dan aplikasi.

Bisakah aku menulis dan menjalankan kode dalam pelajaran Data Science Academy ini?

Ya. Setiap pelajaran Data Science Academy menyertakan editor kode bawaan, jadi kamu menulis dan menjalankan kode nyata langsung di browser dan mendapatkan umpan balik AI instan — tidak diperlukan penyiapan lokal.

Semua pelajaran dalam kursus ini

  1. Mengapa seaborn Lebih Baik daripada matplotlib Mentah
  2. Distribusi: hist, kde, box
  3. Hubungan: scatter dan line
  4. Facet, Hue, dan Style
← Kembali ke Data Science Academy