Discussion:
Theme does not change
g***@gmail.com
2018-09-07 07:59:25 UTC
Permalink
Hi there,

I'm trying to change the font size and get my plot title centered using the
theme(), there is no error when i execute the command. but, i dont think R
executed the theme because there is no changes in my graphs theme.

The script i used are as below.

# Plot contributions_class
contributions %>%
group_by(Gene, SampleType) %>%
mutate(Contribution_perc = ContributionPercentOfAllSamples * 100) %>%
filter(Gene == "K00037") %>%
filter(Contribution_perc > 0) %>%
select(Gene, Class, Contribution_perc) %>%
mutate(Contribution = Contribution_perc/sum(Contribution_perc) * 100) %>%
ggplot(aes(x = SampleType, y = Contribution, fill = Class)) +
ggtitle("Plot of class contributions to \n K00037 (3alpha-hydroxysteroid
3-dehydrogenase)") +
ylab("Percentage of contributions (%)") +
xlab("Sample Group") +
labs(fill = "Class") +
theme_bw() +
theme(plot.title = element_text(hjust = 0.5, size = 18, face = "bold"),
axis.title.x = element_text(size = 14, face = "bold"),
axis.title.y = element_text(size = 14, face = "bold")
) +
geom_bar(stat = "identity") +
theme(axis.text.x = element_text(size = 6)) +
scale_y_continuous(expand = c(0, 0), limits = c(0, 100)) +
theme_light(base_size = 18) +
scale_fill_brewer(palette = "Set3")

Here is me session info.
sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_Malaysia.1252 LC_CTYPE=English_Malaysia.1252
LC_MONETARY=English_Malaysia.1252
[4] LC_NUMERIC=C LC_TIME=English_Malaysia.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] bindrcpp_0.2.2 RColorBrewer_1.1-2 dplyr_0.7.6 btools_0.0.1
ggplot2_3.0.0
[6] phyloseq_1.24.2

loaded via a namespace (and not attached):
[1] tidyselect_0.2.4 reshape2_1.4.3 purrr_0.2.5
splines_3.5.1 lattice_0.20-35
[6] rhdf5_2.24.0 colorspace_1.3-2 stats4_3.5.1
yaml_2.2.0 mgcv_1.8-24
[11] utf8_1.1.4 survival_2.42-6 rlang_0.2.2
pillar_1.3.0 glue_1.3.0
[16] withr_2.1.2 BiocGenerics_0.26.0 foreach_1.4.4
plyr_1.8.4 bindr_0.1.1
[21] stringr_1.3.1 zlibbioc_1.26.0 Biostrings_2.48.0
munsell_0.5.0 gtable_0.2.0
[26] devtools_1.13.6 memoise_1.1.0 codetools_0.2-15
labeling_0.3 Biobase_2.40.0
[31] permute_0.9-4 IRanges_2.14.11 biomformat_1.8.0
parallel_3.5.1 fansi_0.3.0
[36] Rcpp_0.12.18 scales_1.0.0 vegan_2.5-2
S4Vectors_0.18.3 jsonlite_1.5
[41] XVector_0.20.0 digest_0.6.16 stringi_1.1.7
grid_3.5.1 ade4_1.7-11
[46] cli_1.0.0 tools_3.5.1 magrittr_1.5
lazyeval_0.2.1 tibble_1.4.2
[51] cluster_2.0.7-1 crayon_1.3.4 ape_5.1
pkgconfig_2.0.2 MASS_7.3-50
[56] Matrix_1.2-14 data.table_1.11.4 assertthat_0.2.0
rstudioapi_0.7 iterators_1.0.10
[61] Rhdf5lib_1.2.1 R6_2.2.2 multtest_2.36.0
igraph_1.2.2 nlme_3.1-137
[66] compiler_3.5.1

Is there something wrong with the code ?

Thank you.

Regards,
Goh.
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ***@googlegroups.com
To unsubscribe: email ggplot2+***@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Bri On
2018-09-07 10:01:11 UTC
Permalink
Hi there,
I think you have too many settings going on which are overwriting each other (in this case: theme_light). Please consider consolidating your theme customizations, and then place them at the very back of your ggplot additions.
If that doesn't help send a reprex.
HTHBrian
Post by g***@gmail.com
Hi there,
I'm trying to change the font size and get my plot title centered using the theme(), there is no error when i execute the command. but, i dont think R executed the theme because there is no changes in my graphs theme.
The script i used are as below.
# Plot contributions_class
contributions %>% 
  group_by(Gene, SampleType) %>%
  mutate(Contribution_perc = ContributionPercentOfAllSamples * 100) %>%
  filter(Gene == "K00037") %>%
  filter(Contribution_perc > 0) %>%
  select(Gene, Class, Contribution_perc) %>%
  mutate(Contribution = Contribution_perc/sum(Contribution_perc) * 100) %>%
  ggplot(aes(x = SampleType, y = Contribution, fill = Class)) + 
  ggtitle("Plot of class contributions to \n K00037 (3alpha-hydroxysteroid 3-dehydrogenase)") +
  ylab("Percentage of contributions (%)") +
  xlab("Sample Group") +
  labs(fill = "Class") +
  theme_bw() +
  theme(plot.title = element_text(hjust = 0.5, size = 18, face = "bold"),
    axis.title.x = element_text(size = 14, face = "bold"),
    axis.title.y = element_text(size = 14, face = "bold")
  ) +
  geom_bar(stat = "identity") + 
  theme(axis.text.x = element_text(size = 6)) + 
  scale_y_continuous(expand = c(0, 0), limits = c(0, 100)) + 
  theme_light(base_size = 18) + 
  scale_fill_brewer(palette = "Set3")
 Here is me session info.
sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
[1] LC_COLLATE=English_Malaysia.1252  LC_CTYPE=English_Malaysia.1252    LC_MONETARY=English_Malaysia.1252
[4] LC_NUMERIC=C                      LC_TIME=English_Malaysia.1252    
[1] stats     graphics  grDevices utils     datasets  methods   base     
[1] bindrcpp_0.2.2     RColorBrewer_1.1-2 dplyr_0.7.6        btools_0.0.1       ggplot2_3.0.0     
[6] phyloseq_1.24.2   
 [1] tidyselect_0.2.4    reshape2_1.4.3      purrr_0.2.5         splines_3.5.1       lattice_0.20-35    
 [6] rhdf5_2.24.0        colorspace_1.3-2    stats4_3.5.1        yaml_2.2.0          mgcv_1.8-24        
[11] utf8_1.1.4          survival_2.42-6     rlang_0.2.2         pillar_1.3.0        glue_1.3.0         
[16] withr_2.1.2         BiocGenerics_0.26.0 foreach_1.4.4       plyr_1.8.4          bindr_0.1.1        
[21] stringr_1.3.1       zlibbioc_1.26.0     Biostrings_2.48.0   munsell_0.5.0       gtable_0.2.0       
[26] devtools_1.13.6     memoise_1.1.0       codetools_0.2-15    labeling_0.3        Biobase_2.40.0     
[31] permute_0.9-4       IRanges_2.14.11     biomformat_1.8.0    parallel_3.5.1      fansi_0.3.0        
[36] Rcpp_0.12.18        scales_1.0.0        vegan_2.5-2         S4Vectors_0.18.3    jsonlite_1.5       
[41] XVector_0.20.0      digest_0.6.16       stringi_1.1.7       grid_3.5.1          ade4_1.7-11        
[46] cli_1.0.0           tools_3.5.1         magrittr_1.5        lazyeval_0.2.1      tibble_1.4.2       
[51] cluster_2.0.7-1     crayon_1.3.4        ape_5.1             pkgconfig_2.0.2     MASS_7.3-50        
[56] Matrix_1.2-14       data.table_1.11.4   assertthat_0.2.0    rstudioapi_0.7      iterators_1.0.10   
[61] Rhdf5lib_1.2.1      R6_2.2.2            multtest_2.36.0     igraph_1.2.2        nlme_3.1-137       
[66] compiler_3.5.1  
Is there something wrong with the code ? 
Thank you.
Regards,
Goh.
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
More options: http://groups.google.com/group/ggplot2
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
For more options, visit https://groups.google.com/d/optout.
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ***@googlegroups.com
To unsubscribe: email ggplot2+***@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...