106106# ' ppc_stat(y, yrep, stat = "sd") + legend_none()
107107# ' mcmc_areas(x, regex_pars = "beta")
108108# '
109- # ' ###########################
110- # ' ### ColorBrewer schemes ###
111- # ' ###########################
109+ # ' ##########################
110+ # ' ### ColorBrewer scheme ###
111+ # ' ##########################
112112# ' color_scheme_set("brewer-Spectral")
113+ # ' color_scheme_view()
113114# ' mcmc_trace(x, pars = "sigma")
114115# '
115116# ' ###########################
119120# ' "#ffad33", "#e68a00",
120121# ' "#995c00", "#663d00")
121122# ' color_scheme_set(orange_scheme)
123+ # ' color_scheme_view()
122124# ' mcmc_areas(x, regex_pars = "alpha")
123125# ' mcmc_dens_overlay(x)
124126# ' ppc_stat(y, yrep, stat = "var") + legend_none()
@@ -171,20 +173,6 @@ color_scheme_get <- function(scheme, i) {
171173 scheme [i ]
172174}
173175
174- # ' @export
175- print.bayesplot_scheme <- function (x , ... ) {
176- tab <- data.frame (unlist(x , use.names = FALSE ),
177- stringsAsFactors = FALSE )
178- colnames(tab ) <- attr(x , " scheme_name" ) %|| % " hex_color"
179- print(tab , ... )
180- }
181- # ' @export
182- plot.bayesplot_scheme <- function (x , ... ) {
183- scheme <- attr(x , " scheme_name" ) %|| % stop(" Scheme name not found." )
184- plot_scheme(scheme )
185- }
186-
187-
188176# ' @rdname bayesplot-colors
189177# ' @export
190178color_scheme_view <- function (scheme = NULL ) {
@@ -198,6 +186,17 @@ color_scheme_view <- function(scheme = NULL) {
198186 )
199187}
200188
189+ # ' @export
190+ print.bayesplot_scheme <- function (x , ... ) {
191+ tab <- data.frame (unlist(x , use.names = FALSE ), stringsAsFactors = FALSE )
192+ colnames(tab ) <- attr(x , " scheme_name" ) %|| % " hex_color"
193+ print(tab , ... )
194+ }
195+ # ' @export
196+ plot.bayesplot_scheme <- function (x , ... ) {
197+ scheme <- attr(x , " scheme_name" ) %|| % stop(" Scheme name not found." )
198+ plot_scheme(scheme )
199+ }
201200
202201
203202# internal -----------------------------------------------------------------
@@ -207,25 +206,17 @@ color_scheme_view <- function(scheme = NULL) {
207206plot_scheme <- function (scheme = NULL ) {
208207 if (is.null(scheme )) {
209208 x <- color_scheme_get()
210- x_name <- " "
211209 } else {
212210 x <- color_scheme_get(scheme )
213- x_name <- factor (scheme )
214211 }
215212
216213 color_data <- data.frame (
217- name = x_name ,
214+ name = factor (attr( x , " scheme_name " )) ,
218215 group = factor (names(x ), levels = rev(names(x ))),
219216 value = rep(1 , length(x ))
220217 )
221- ggplot(
222- color_data ,
223- aes_(
224- x = ~ name ,
225- y = ~ value ,
226- fill = ~ group
227- )
228- ) +
218+
219+ ggplot(color_data , aes_(x = ~ name , y = ~ value , fill = ~ group )) +
229220 geom_bar(
230221 width = .5 ,
231222 stat = " identity" ,
0 commit comments