Skip to content

Commit

Permalink
Merge pull request #148 from spsanderson/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
spsanderson committed Jul 18, 2022
2 parents bb3b564 + 19cfd6d commit 02d5566
Show file tree
Hide file tree
Showing 12 changed files with 125 additions and 39 deletions.
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export(enquo)
export(enquos)
export(expr)
export(gartner_magic_chart_plt)
export(hr_scale_color_colorblind)
export(hr_scale_fill_colorblind)
export(kmeans_mapped_tbl)
export(kmeans_obj)
export(kmeans_scree_data_tbl)
Expand All @@ -24,8 +26,6 @@ export(los_ra_index_summary_tbl)
export(named_item_list)
export(opt_bin)
export(save_to_excel)
export(scale_color_colorblind)
export(scale_fill_colorblind)
export(service_line_augment)
export(service_line_vec)
export(sql_left)
Expand Down
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
None

## New Features
1. Fix #139 - Add functions `color_blind()` `scale_fill_colorblind()`
and `scale_color_colorblind()`
1. Fix #139 - Add functions `color_blind()` `hr_scale_fill_colorblind()`
and `hr_scale_color_colorblind()`
2. Fix #138 - Add parameter to `gartner_magic_chart_plt()` function in order to
size points accoring to a column in a data.frame/tibble.

Expand Down
3 changes: 1 addition & 2 deletions R/gartner_magic_chart.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' @param .data The data set you want to plot
#' @param .x_col The x-axis for the plot
#' @param .y_col The y-axis for the plot
#' @param .plot_col_size The default is NULL, if you want to size the dots by
#' @param .point_size_col The default is NULL, if you want to size the dots by
#' a column in the data.frame/tibble then enter the column name here.
#' @param .y_lab The y-axis label
#' @param .x_lab The x-axis label
Expand All @@ -17,7 +17,6 @@
#' @param .tl_lbl The top left label
#' @param .bl_lbl The bottom left label
#' @param .br_lbl The bottom right label
#' @param .point_size The column you want to pass as a point size to `ggplot2`
#'
#' @details
#' - Supply a data frame with at least two continuous variables to plot against
Expand Down
53 changes: 49 additions & 4 deletions R/pallette-color-blind.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
#' Provide Colorblind Compliant Colors
#'
#' @author Steven P. Sanderson II, MPH
#'
#' @details
#' This function is used in others in order to help render plots for those that
#' are color blind.
#'
#' @description
#' 8 Hex RGB color definitions suitable for charts for colorblind people.
#'
#' @examples
#' color_blind()
#'
#' @return
#' A vector of 8 Hex RGB definitions.
#'
#' @export
color_blind <- function(){
c("#000000", "#E69F00", "#56B4E9",
Expand All @@ -10,22 +23,54 @@ color_blind <- function(){
}

#' Provide Colorblind Compliant Colors
#'
#' @author Steven P. Sanderson II, MPH
#'
#' @details
#' This function is used in others in order to help render plots for those that
#' are color blind.
#'
#' @description
#' 8 Hex RGB color definitions suitable for charts for colorblind people.
#'
#' @param ... Data passed in from a `ggplot` object
#' @param theme Right now this is `hr` only. Anything else will render an error.
#'
#' @return
#' A `gggplot` layer
#'
#' @export
scale_fill_colorblind <- function(..., theme = "td") {
hr_scale_fill_colorblind <- function(..., theme = "hr") {

pal <- switch(theme,
"td" = unname(color_blind()) %>% rep(100)
"hr" = unname(color_blind()) %>% rep(100)
)

ggplot2::scale_fill_manual(values = pal)
}

#' Provide Colorblind Compliant Colors
#'
#' @author Steven P. Sanderson II, MPH
#'
#' @details
#' This function is used in others in order to help render plots for those that
#' are color blind.
#'
#' @description
#' 8 Hex RGB color definitions suitable for charts for colorblind people.
#'
#' @param ... Data passed in from a `ggplot` object
#' @param theme Right now this is `hr` only. Anything else will render an error.
#'
#' @return
#' A `gggplot` layer
#'
#' @export
scale_color_colorblind = function(..., theme = "td") {
hr_scale_color_colorblind = function(..., theme = "hr") {

pal <- switch(theme,
"td" = unname(color_blind()) %>% rep(100)
"hr" = unname(color_blind()) %>% rep(100)
)

ggplot2::scale_color_manual(values = pal)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ library(healthyR)
library(timetk)

ts_signature_tbl(.data = m4_daily, .date_col = date)
#> # A tibble: 17,578 x 31
#> # A tibble: 17,578 × 31
#> id date value index.num diff year year.iso half quarter month
#> <fct> <date> <dbl> <dbl> <dbl> <int> <int> <int> <int> <int>
#> 1 D410 1978-06-23 9109. 267408000 NA 1978 1978 1 2 6
Expand All @@ -74,7 +74,7 @@ ts_signature_tbl(.data = m4_daily, .date_col = date)
#> 8 D410 1978-06-30 9084. 268012800 86400 1978 1978 1 2 6
#> 9 D410 1978-07-01 9081. 268099200 86400 1978 1978 2 3 7
#> 10 D410 1978-07-02 9047. 268185600 86400 1978 1978 2 3 7
#> # ... with 17,568 more rows, and 21 more variables: month.xts <int>,
#> # with 17,568 more rows, and 21 more variables: month.xts <int>,
#> # month.lbl <ord>, day <int>, hour <int>, minute <int>, second <int>,
#> # hour12 <int>, am.pm <int>, wday <int>, wday.xts <int>, wday.lbl <ord>,
#> # mday <int>, qday <int>, yday <int>, mweek <int>, week <int>,
Expand Down
14 changes: 14 additions & 0 deletions man/color_blind.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified man/figures/README-gartner_chart-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 3 additions & 5 deletions man/gartner_magic_chart_plt.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions man/hr_scale_color_colorblind.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions man/hr_scale_fill_colorblind.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions man/scale_color_colorblind.Rd

This file was deleted.

11 changes: 0 additions & 11 deletions man/scale_fill_colorblind.Rd

This file was deleted.

0 comments on commit 02d5566

Please sign in to comment.