> For the complete documentation index, see [llms.txt](https://larhues-personal-organization.gitbook.io/intro-to-data-visualization/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://larhues-personal-organization.gitbook.io/intro-to-data-visualization/data-explanation/data-explanation-with-plotly/accessibility.md).

# 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**

```python
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**

```python
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.
