Intro to Data Visualization
  • Introduction
  • Getting started
    • Introduction to Pandas
    • Accessing Files on Colab
    • Reviewing Data
      • Understanding type(data) in Pandas
    • Data Types
      • Categorical Data
      • Numeric Data
      • Temporal Data
      • Geographic Data
    • How to Check Data Type
    • Slicing and Subsetting DataFrames
    • Aggregating Data
  • Visualization Types
    • Exploratory Process
    • Explanatory Process
  • data exploration
    • Exploration Overview
    • Exploration with Plotly
      • Exploring Distributions
      • Exploring Relationships
      • Exploring with Regression Plots
      • Exploring Correlations
      • Exploring Categories
      • Exploring Time Series
      • Exploring Stocks with Candlestick
      • Exploring with Facets
      • Exploring with Subplots
    • Exploring with AI
  • Data Explanation
    • Data Explanation with Plotly
      • Using Text
      • Using Annotations
      • Using Color
      • Using Shape
      • Accessibility
      • Using Animations
    • Use Cases
  • Exercises and examples
    • Stock Market
      • Loading Yahoo! Finance Data
      • Use Cases for YF
      • Exploring YF Data
      • Understanding Boeing Data Over Time
      • Polishing the visualization
      • Analyzing with AI
      • Comparisons
    • The Gapminder Dataset
      • Loading the Gapminder Data
      • Use Cases
      • Exploring the Data
      • Exporting a Static Image
Powered by GitBook
On this page
  1. Data Explanation
  2. Data Explanation with Plotly

Accessibility

Plotly Color Palettes and Color Maps for Colorblind-Friendly Visualizations

When creating visualizations, it is essential to consider accessibility, especially for viewers with color vision deficiencies. Plotly provides several built-in color palettes and the flexibility to customize color maps to ensure inclusivity and clarity for all users. Below are some colorblind-friendly options and tips for their use.


Colorblind-Friendly Plotly Color Palettes

Plotly includes predefined color scales that are designed to be accessible to colorblind audiences. Here are some of the most commonly recommended color scales:

  1. Viridis:

    • A perceptually uniform color scale that works well for sequential data.

    • It transitions from dark purple to yellow, maintaining distinguishable contrasts.

  2. Cividis:

    • Specifically designed to be colorblind-friendly.

    • It uses a blue-to-yellow gradient and is excellent for sequential data.

  3. Plotly’s Colorblind Palette:

    • A categorical palette explicitly designed for colorblind users.

    • Includes colors that are easily distinguishable even for viewers with red-green colorblindness.

  4. Inferno and Plasma:

    • Both are perceptually uniform scales, transitioning through a range of warm colors.

    • Suitable for colorblind audiences and high-contrast visualizations.


Using Colorblind-Friendly Color Scales in Plotly

You can specify these color scales directly in your Plotly visualizations. Here’s an example:

Sequential Data Example

import plotly.express as px
import pandas as pd

# Sample data
data = {
    'Category': ['A', 'B', 'C', 'D'],
    'Values': [10, 20, 15, 25]
}
df = pd.DataFrame(data)

# Using a colorblind-friendly scale
fig = px.bar(
    df, 
    x='Category', 
    y='Values', 
    color='Values', 
    color_continuous_scale='Viridis',  # Colorblind-friendly scale
    title='Bar Chart with Viridis Scale'
)
fig.show()

Categorical Data Example

pythonCopy code# Custom colorblind-friendly palette for categories
custom_colors = {
    'A': '#377eb8',  # Blue
    'B': '#4daf4a',  # Green
    'C': '#ff7f00',  # Orange
    'D': '#984ea3'   # Purple
}

fig = px.bar(
    df, 
    x='Category', 
    y='Values', 
    color='Category', 
    color_discrete_map=custom_colors, 
    title='Bar Chart with Custom Colorblind-Friendly Palette'
)
fig.show()

Design Tips for Colorblind-Friendly Visualizations

  1. Use Distinct Colors:

    • Avoid red and green combinations, as they are indistinguishable for many colorblind users.

    • Leverage blue, orange, purple, and yellow for clear differentiation.

  2. Provide Alternative Cues:

    • Use patterns, shapes, or annotations alongside colors to convey information.

    • For example, dashed lines or distinct markers in line charts.

  3. Test Your Visualizations:

    • Use tools like Coblis to simulate how your visualization appears to colorblind individuals.

  4. Avoid Excessive Colors:

    • Stick to a limited palette to reduce confusion and ensure clarity.

By integrating these practices with Plotly’s color maps, you can create accessible and visually appealing visualizations for all audiences.

PreviousUsing ShapeNextUsing Animations

Last updated 3 months ago