set_theme = FALSE doesn't work
neilpanchal opened this issue · comments
Objective: To only update the palette with custom colors, nothing else.
Tried:
my_palette <- define_palette(
swatch = structure(c(
'#fdf6e3',
'#207DE8', '#1ABC9C',
'#E3CA09', '#DB46BE',
'#B3CF00', '#E63535',
'#9959EB', '#EB9A02')),
gradient = c(low = '#f1c40f', high = '#c0392b')
)
ggthemr(my_palette, set_theme = FALSE)
Returns an error and a large printed text (a portion of it shown below).
$theme
List of 58
$ line :List of 6
..$ colour : chr "#6e6e6e"
..$ size : num 0.5
..$ linetype : num 1
..$ lineend : chr "butt"
..$ arrow : logi FALSE
..$ inherit.blank: logi TRUE
..- attr(*, "class")= chr [1:2] "element_line" "element"
$ rect :List of 5
..$ fill : chr "white"
..$ colour : chr "#444444"
..$ size : num 0.5
..$ linetype : num 1
..$ inherit.blank: logi TRUE
..- attr(*, "class")= chr [1:2] "element_rect" "element"
$ text :List of 11
..$ family : chr ""
..$ face : chr "plain"
..$ colour : chr "#444444"
..$ size : num 12
..$ hjust : num 0.5
..$ vjust : num 0.5
..$ angle : num 0
..$ lineheight : num 0.9
..$ margin :Classes 'margin', 'unit' atomic [1:4] 0 0 0 0
.. .. ..- attr(*, "valid.unit")= int 8
.. .. ..- attr(*, "unit")= chr "pt"
..$ debug : logi FALSE
..$ inherit.blank: logi TRUE
..- attr(*, "class")= chr [1:2] "element_text" "element"
$ axis.title :List of 11
..$ family : NULL
..$ face : chr "bold"
..$ colour : chr "#444444"
..$ size : NULL
..$ hjust : NULL
..$ vjust : NULL
..$ angle : NULL
..$ lineheight : NULL
..$ margin : NULL
..$ debug : NULL
..$ inherit.blank: logi TRUE
..- attr(*, "class")= chr [1:2] "element_text" "element"
$ axis.title.x :List of 11
..$ family : NULL
..$ face : NULL
..$ colour : NULL
..$ size : NULL
..$ hjust : NULL
..$ vjust : num -0.78
..$ angle : NULL
..$ lineheight : NULL
..$ margin :Classes 'margin', 'unit' atomic [1:4] 0 0 0 0
.. .. ..- attr(*, "valid.unit")= int 8
.. .. ..- attr(*, "unit")= chr "pt"
..$ debug : logi FALSE
..$ inherit.blank: logi TRUE
Full printed output: https://gist.github.com/neilpanchal/685c02fe19b796adbb3c8692690d33ed
My session information:
R version 3.3.3 (2017-03-06)
Platform: x86_64-apple-darwin16.4.0 (64-bit)
Running under: macOS Sierra 10.12.4
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggthemr_1.1.0 dplyr_0.5.0 purrr_0.2.2
[4] readr_1.1.0 tidyr_0.6.1 tibble_1.3.0
[7] ggplot2_2.2.1 tidyverse_1.1.1.9000 extrafont_0.17
loaded via a namespace (and not attached):
[1] Rcpp_0.12.10 plyr_1.8.4 forcats_0.2.0
[4] tools_3.3.3 digest_0.6.12 uuid_0.1-2
[7] lubridate_1.6.0 gtable_0.2.0 jsonlite_1.4
[10] evaluate_0.10 nlme_3.1-131 lattice_0.20-34
[13] psych_1.7.3.21 IRdisplay_0.4.4 DBI_0.6-1
[16] IRkernel_0.8.6.9000 parallel_3.3.3 haven_1.0.0
[19] Rttf2pt1_1.3.4 xml2_1.1.1 httr_1.2.1
[22] repr_0.12.0 stringr_1.2.0 hms_0.3
[25] grid_3.3.3 R6_2.2.0 readxl_0.1.1
[28] foreign_0.8-67 pbdZMQ_0.2-5 modelr_0.1.0
[31] reshape2_1.4.2 extrafontdb_1.0 magrittr_1.5
[34] scales_0.4.1 rvest_0.3.2 assertthat_0.2.0
[37] mnormt_1.5-5 colorspace_1.3-2 labeling_0.3
[40] stringi_1.1.5 lazyeval_0.2.0 munsell_0.4.3
[43] broom_0.4.2 crayon_1.3.2
How can I update a custom palette, and leave everything else unchanged?
You mentioned ggthemr(my_palette, set_theme = FALSE)
command returned an error, but I don't see any errors in the output. Can you clarify?
@sainathadapa Sorry, by error I meant erroneous output. I can't imagine a several page output as an expected outcome, am I doing something wrong?
If you want to apply the ggthemr theme using the custom palette you have defined, use ggthemr(my_palette, set_theme = TRUE)
. Instead if you want to update only specific components, save the object from tmp <- ggthemr(my_palette, set_theme = FALSE)
, and update the required component manually. e.g.: ggplot(...) + geom_point(...) + tmp$scales$scale_fill_discrete()
. Refer to this part of the README for more details.
@sainathadapa Thank you. I've attempted to follow the instructions with no success. Please take a look here:
https://github.com/neilpanchal/ggthemr-test/blob/master/ggthemr-test.ipynb
Colors for geom_point are managed by the 'color' parameter, and not 'fill' parameter in ggplot. You wrote 'color' in geom_point, and not 'fill' here (rightly so) ggplot(data = mpg) + geom_point(mapping = aes(x = displ, y = hwy, color = class), size=2)
. But you haven't used the right scale. Use dust_theme$scales$scale_colour_discrete()
and not dust_theme$scales$scale_fill_discrete()
@sainathadapa Thank you so much. I am starting to understand the underlying mechanisms 😃