What is the purpose of White figure style in seaborn?

The "white" figure style in Seaborn is a predefined style that provides a clean and minimalistic appearance to plots. It emphasizes data representation by creating visually appealing and easy-to-read visualizations while reducing distractions.

Key Features of White Style

Background and Grid

The white style sets a neutral white background and removes grid lines by default, creating an uncluttered appearance that draws attention to the data elements ?

import seaborn as sns
import matplotlib.pyplot as plt

# Set white style
sns.set_style("white")

# Create sample data
x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]

plt.figure(figsize=(8, 6))
plt.scatter(x, y, s=100, alpha=0.7)
plt.xlabel("X Values")
plt.ylabel("Y Values") 
plt.title("White Style Example")
plt.show()

Axes and Labels

The white style uses black axes and tick labels, providing high contrast against the white background for enhanced readability ?

import seaborn as sns
import matplotlib.pyplot as plt

# Compare white style with default
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 5))

# Default style
sns.set_style("darkgrid")
ax1.plot([1, 2, 3, 4], [1, 4, 2, 3], marker='o')
ax1.set_title("Default Style")
ax1.set_xlabel("X")
ax1.set_ylabel("Y")

# White style
sns.set_style("white")
ax2.plot([1, 2, 3, 4], [1, 4, 2, 3], marker='o')
ax2.set_title("White Style")
ax2.set_xlabel("X")
ax2.set_ylabel("Y")

plt.tight_layout()
plt.show()

Benefits of White Style

Feature White Style Benefit
Background Pure white Neutral, professional appearance
Grid Lines Removed Cleaner, less cluttered
Colors Light, vibrant palette Better data distinction
Borders Minimal Focus on data content

Practical Example

Here's how to create a complete visualization using the white style with multiple plot types ?

import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np

# Set white style
sns.set_style("white")

# Generate sample data
np.random.seed(42)
data = np.random.randn(100, 2)
categories = np.random.choice(['A', 'B', 'C'], 100)

# Create subplots
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, figsize=(12, 10))

# Scatter plot
ax1.scatter(data[:, 0], data[:, 1], alpha=0.6)
ax1.set_title("Scatter Plot")
ax1.set_xlabel("X")
ax1.set_ylabel("Y")

# Line plot
x_line = np.linspace(0, 10, 50)
y_line = np.sin(x_line)
ax2.plot(x_line, y_line, linewidth=2)
ax2.set_title("Line Plot")
ax2.set_xlabel("X")
ax2.set_ylabel("sin(X)")

# Histogram
ax3.hist(data[:, 0], bins=20, alpha=0.7, edgecolor='black')
ax3.set_title("Histogram")
ax3.set_xlabel("Values")
ax3.set_ylabel("Frequency")

# Box plot
sns.boxplot(x=categories, y=data[:, 0], ax=ax4)
ax4.set_title("Box Plot")
ax4.set_xlabel("Category")
ax4.set_ylabel("Values")

plt.tight_layout()
plt.show()

When to Use White Style

The white style is ideal for professional presentations, publications, and when you want to emphasize data clarity. It works particularly well for printed materials and formal reports where a clean, minimalistic appearance is preferred.

Conclusion

The white figure style in Seaborn creates clean, professional-looking plots by removing visual clutter and using high-contrast elements. It's perfect for presentations and publications where data clarity and minimalistic design are priorities.

---
Updated on: 2026-03-27T10:55:22+05:30

370 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements