Plot with Top 3 Showing All Dataset on x Axis

library(tidyverse)
  
diamonds %>% 
  group_by(clarity) %>%
  summarise(carat = mean(carat)) %>%
  head(3) %>% 
  ggplot(aes(x = clarity, 
             y = carat)) + 
  geom_col()


diamonds %>% 
  group_by(clarity) %>%
  summarise(carat = mean(carat)) %>%
  head(3) %>% 
  ggblanket::gg_col(x = clarity, 
                    y = carat)
#> Scale for x is already present.
#> Adding another scale for x, which will replace the existing scale.
#> Scale for y is already present.
#> Adding another scale for y, which will replace the existing scale.

Created on 2023-06-12 with reprex v2.0.2

Session info
sessionInfo()
#> R version 4.3.0 (2023-04-21)
#> Platform: x86_64-apple-darwin20 (64-bit)
#> Running under: macOS Ventura 13.4
#> 
#> Matrix products: default
#> BLAS:   /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRblas.0.dylib 
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0
#> 
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#> 
#> time zone: America/Sao_Paulo
#> tzcode source: internal
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#>  [1] lubridate_1.9.2 forcats_1.0.0   stringr_1.5.0   dplyr_1.1.2    
#>  [5] purrr_1.0.1     readr_2.1.4     tidyr_1.3.0     tibble_3.2.1   
#>  [9] ggplot2_3.4.2   tidyverse_2.0.0
#> 
#> loaded via a namespace (and not attached):
#>  [1] styler_1.10.1     utf8_1.2.3        generics_0.1.3    xml2_1.3.4       
#>  [5] stringi_1.7.12    hms_1.1.3         digest_0.6.31     magrittr_2.0.3   
#>  [9] evaluate_0.21     grid_4.3.0        timechange_0.2.0  fastmap_1.1.1    
#> [13] R.oo_1.25.0       R.cache_0.16.0    R.utils_2.12.2    fansi_1.0.4      
#> [17] scales_1.2.1      cli_3.6.1         rlang_1.1.1       R.methodsS3_1.8.2
#> [21] ggblanket_2.0.0   munsell_0.5.0     reprex_2.0.2      withr_2.5.0      
#> [25] yaml_2.3.7        tools_4.3.0       tzdb_0.4.0        colorspace_2.1-0 
#> [29] curl_5.0.1        vctrs_0.6.2       R6_2.5.1          lifecycle_1.0.3  
#> [33] snakecase_0.11.0  fs_1.6.2          pkgconfig_2.0.3   pillar_1.9.0     
#> [37] gtable_0.3.3      glue_1.6.2        xfun_0.39         tidyselect_1.2.0 
#> [41] highr_0.10        rstudioapi_0.14   knitr_1.43        farver_2.1.1     
#> [45] htmltools_0.5.5   rmarkdown_2.22    labeling_0.4.2    compiler_4.3.0

Works for me

library(tidyverse)
library(ggblanket)
diamonds %>% 
  group_by(clarity) %>%
  summarise(carat = mean(carat)) %>%
  head(3) %>%
  ggblanket::gg_col(x = clarity, 
                    y = carat)
#> Scale for x is already present.
#> Adding another scale for x, which will replace the existing scale.
#> Scale for y is already present.
#> Adding another scale for y, which will replace the existing scale.


diamonds %>% 
  group_by(clarity) %>%
  summarise(carat = mean(carat)) %>%
  head(3) %>%
  mutate(clarity = forcats::fct_drop(clarity)) %>%
  ggblanket::gg_col(x = clarity, 
                    y = carat)
#> Scale for x is already present.
#> Adding another scale for x, which will replace the existing scale.
#> Scale for y is already present.
#> Adding another scale for y, which will replace the existing scale.

Created on 2023-06-13 with reprex v2.0.2

thanks @davidhodge931 it worked for me when I added fct_drop to it, I was sure that it worked before without this parameter, do you know if something changed? I'll restart my section as well to see if anything improves

Weird. The x is a factor, so ggblanket defaults to including all levels unless you drop unused levels. So it should look like this. Make sure you restart

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.