DEV Community

Cover image for Seaborn Cheat Sheet
Arum Puri
Arum Puri

Posted on

Seaborn Cheat Sheet

A concise guide to Seaborn for creating attractive and informative statistical graphics in Python.

Installation

pip install seaborn

Enter fullscreen mode Exit fullscreen mode

Importing Seaborn

import seaborn as sns
import matplotlib.pyplot as plt

Enter fullscreen mode Exit fullscreen mode

1. Relational Plots

Function: sns.relplot()

Creates scatter or line plots to show relationships between variables.

Image description

- Example: Scatter Plot

sns.relplot(data=tips, x="total_bill", y="tip", hue="time", kind="scatter")

Enter fullscreen mode Exit fullscreen mode

- Example: Line Plot

sns.relplot(data=tips, x="size", y="tip", kind="line", hue="day", style="time")

Enter fullscreen mode Exit fullscreen mode

Common Attribute for Relational Plots
Image description


2. Distribution Plots

Function: sns.displot()

Visualizes distributions with histograms, KDEs, rugs, or ECDFs.

Image description

- Histogram Example

sns.displot(data=penguins, x="flipper_length_mm", kind="hist", bins=20)

Enter fullscreen mode Exit fullscreen mode

- KDE Plot Example

sns.displot(data=penguins, x="flipper_length_mm", kind="kde", fill=True)

Enter fullscreen mode Exit fullscreen mode

Common Attribute for Distribution Plots
Image description


3. Categorical Plots

Function: sns.catplot()

Visualizes categorical data using multiple plot types.

Image description

- Example: Bar Plot

sns.catplot(data=tips, x="day", y="total_bill", kind="bar", hue="sex")

Enter fullscreen mode Exit fullscreen mode

- Example: Violin Plot

sns.catplot(data=tips, x="day", y="total_bill", kind="violin", split=True, hue="sex")

Enter fullscreen mode Exit fullscreen mode

Common Attribute for Categorical Plots
Image description


4. Color Palettes (palette)

Image description

Custom Palettes

  • HUSL Palette: sns.color_palette("husl", n_colors=8)
  • CUBEHELIX Palette: sns.color_palette("cubehelix", n_colors=8)
  • Custom HEX Colors: ["#4c72b0", "#55a868", "#c44e52"]
  • Blend Two Colors: sns.blend_palette(["red", "blue"], n_colors=8)

Style Attributes

Image description


Advanced Distribution Attributes

Image description


Common Attributes for All Plots

Image description

Image of AssemblyAI tool

Transforming Interviews into Publishable Stories with AssemblyAI

Insightview is a modern web application that streamlines the interview workflow for journalists. By leveraging AssemblyAI's LeMUR and Universal-2 technology, it transforms raw interview recordings into structured, actionable content, dramatically reducing the time from recording to publication.

Key Features:
🎥 Audio/video file upload with real-time preview
🗣️ Advanced transcription with speaker identification
⭐ Automatic highlight extraction of key moments
✍️ AI-powered article draft generation
📤 Export interview's subtitles in VTT format

Read full post

Top comments (0)

Billboard image

Try REST API Generation for MS SQL Server.

DevOps for Private APIs. With DreamFactory API Generation, you get:

  • Auto-generated live APIs mapped from database schema
  • Interactive Swagger API documentation
  • Scripting engine to customize your API
  • Built-in role-based access control

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay