8000 Add color_blind() · Issue #139 · spsanderson/healthyR · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add color_blind() #139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spsanderson opened this issue May 10, 2022 · 2 comments
Closed

Add color_blind() #139

spsanderson opened this issue May 10, 2022 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@spsanderson
Copy link
Owner

No description provided.

@spsanderson spsanderson self-assigned this May 10, 2022
@spsanderson spsanderson added this to the healthyR 0.2.0 milestone May 10, 2022
@spsanderson spsanderson added the enhancement New feature or request label May 10, 2022
@spsanderson
Copy link
Owner Author
spsanderson commented May 10, 2022

Functions:

#' Provide Colorblind Compliant Colors 
#' 
#' 8 Hex RGB color defintions suitable for charts for colorblind people.
#' 
#' @export
color_blind <- function(){
  c("#000000", "#E69F00", "#56B4E9",
    "#009E73", "#F0E442", "#0072B2",
    "#D55E00", "#CC79A7")
}

# Fill
ts_scale_fill_colorblind = function(.ColorList = 2L:8L, ...){
  ggplot2::scale_fill_discrete(..., type = color_blind())
}

# Color
ts_scale_color_colorblind = function(.ColorList = 2L:8L, ...){
  ggplot2::scale_color_discrete(..., type = color_blind())
}

Example:

library(tidyverse)

ggplot(
  diamonds,
  aes(clarity, fill = cut)
) +
  geom_bar(position = "dodge") +
  ts_scale_fill_colorblind()

image

@spsanderson
Copy link
Owner Author

@spsanderson spsanderson moved this from Todo to In Progress in @spsanderson's Repository Issue Overview May 10, 2022
Repository owner moved this from In Progress to Done in @spsanderson's Repository Issue Overview May 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

1 participant
0