Skip to content

Commit

Permalink
guide is set to colourbar
Browse files Browse the repository at this point in the history
for continuous/gradient scales
Fixes #26
  • Loading branch information
sainathadapa committed Apr 16, 2018
1 parent 80783e8 commit 0a31bb5
Showing 1 changed file with 34 additions and 9 deletions.
43 changes: 34 additions & 9 deletions R/theme_scales.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,41 @@ theme_scales <- function(palette) {

colours <- palette$swatch[-1]

new_scale_functions <- list(
scale_colour_discrete = function(...) discrete_scale( 'colour', 'ggthemr', discrete_colours(colours), ...),
scale_fill_discrete = function(...) discrete_scale( 'fill', 'ggthemr', discrete_colours(colours), ...),
scale_colour_continuous = function(...) continuous_scale('colour', 'ggthemr', seq_gradient_pal(palette$gradient[['low']], palette$gradient[['high']]), ...),
scale_fill_continuous = function(...) continuous_scale('fill', 'ggthemr', seq_gradient_pal(palette$gradient[['low']], palette$gradient[['high']]), ...),
scale_colour_gradient = function(...) continuous_scale('colour', 'ggthemr', seq_gradient_pal(palette$gradient[['low']], palette$gradient[['high']]), ...),
scale_fill_gradient = function(...) continuous_scale('fill', 'ggthemr', seq_gradient_pal(palette$gradient[['low']], palette$gradient[['high']]), ...)
)
scale_colour_discrete = function(...) discrete_scale('colour', 'ggthemr', discrete_colours(colours), ...)

scale_fill_discrete = function(...) discrete_scale('fill', 'ggthemr', discrete_colours(colours), ...)

scale_colour_continuous = function(...,
low = palette$gradient[['low']],
high = palette$gradient[['high']],
space = "Lab",
guide = "colourbar") {
continuous_scale('colour', 'ggthemr',
seq_gradient_pal(low, high, space),
guide = guide, ...)
}

new_scale_functions
scale_fill_continuous = function(...,
low = palette$gradient[['low']],
high = palette$gradient[['high']],
space = "Lab",
guide = "colourbar") {
continuous_scale('fill', 'ggthemr',
seq_gradient_pal(low, high, space),
guide = guide, ...)
}

list(
scale_colour_discrete = scale_colour_discrete,
scale_color_discrete = scale_colour_discrete,
scale_fill_discrete = scale_fill_discrete,
scale_colour_continuous = scale_colour_continuous,
scale_color_continuous = scale_colour_continuous,
scale_colour_gradient = scale_colour_continuous,
scale_color_gradient = scale_colour_continuous,
scale_fill_continuous = scale_fill_continuous,
scale_fill_gradient = scale_fill_continuous
)
}


Expand Down

0 comments on commit 0a31bb5

Please sign in to comment.