The goal of the profiplots package is to unify graphics
across analyses made by Profinit team. In this document we’re
introducing basic ways to do so. Take a look on the plot
gallery page, too.
To ease the adaptation, there is a pair of functions to set up the
most general option globaly. This affects both baseR and
ggplot2 graphics.
profiplots::set_theme() – to set the profinit-look
globaly. There are two params:
pal_name – color palette to be used by default (ggplot:
for continuous variables only).pal_name_discrete – color palette to be used for
discrete mapping by default (ggplot only).profiplots::profinit_pal.pals().profiplots::unset_theme() – revert the settings.We’re going to use barplot here. For examples of other
plot types see the plot
gallery page. For demonstration purposes, we’re going to tweak
fill palette in ggplto2. Of course this can be applied to
the color versions as well (scale_color_profinit_c,
scale_color_profinit_d).
reds, reds-dark,
blues, blues-dark or greys:blue-red if possible. To create
another gradient, you may use scale_color_gradientand
profinit_cols.blue-white-red palette. To create a
new one, you can use scale_color_gradient2 and
profinit_cols:discrete (6 colors)
and discrete-full (all colors specified in the Visual
identity guidelines document).
exact to FALSE)reds, reds-dark,
blues, blues-dark or greys:blue-red if possible. To create
another gradient, you may use scale_color_gradientand
profinit_cols.
# This way you can define your own palette based on Profinit colors
red_yellow_pal <- grDevices::colorRampPalette(c(profinit_cols("red"), profinit_cols("yellow")))
barplot(
height = sample_df$x,
names.arg = sample_df$category,
border = NA,
col = red_yellow_pal(8),
main = "Example - custom gradient fill (NOT RECOMMEADED)"
)blue-white-red palette. To create a
new one, you can use scale_color_gradient2 and
profinit_cols:
# Create your own diverging palette based on Profinit colors
red_white_pink_pal <- grDevices::colorRampPalette(c(profinit_cols("red"), "white", profinit_cols("pink")))
barplot(
height = sample_df$x,
names.arg = sample_df$category,
border = NA,
col = red_white_pink_pal(8),
main = "Base R - custom diverging fill (NOT RECOMMANDED)"
)discrete (6 colors)
and discrete-full (all colors specified in the Visual
identity guidelines document).
exact to FALSE)sessionInfo()
#> R version 4.2.0 (2022-04-22 ucrt)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 19045)
#>
#> Matrix products: default
#>
#> locale:
#> [1] LC_COLLATE=C
#> [2] LC_CTYPE=English_United Kingdom.utf8
#> [3] LC_MONETARY=English_United Kingdom.utf8
#> [4] LC_NUMERIC=C
#> [5] LC_TIME=English_United Kingdom.utf8
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] ggplot2_3.4.4 profiplots_0.2.3
#>
#> loaded via a namespace (and not attached):
#> [1] highr_0.10 bslib_0.5.1 compiler_4.2.0 pillar_1.9.0
#> [5] jquerylib_0.1.4 tools_4.2.0 digest_0.6.29 jsonlite_1.8.0
#> [9] evaluate_0.23 lifecycle_1.0.3 tibble_3.2.1 gtable_0.3.4
#> [13] pkgconfig_2.0.3 rlang_1.1.1 cli_3.4.1 rstudioapi_0.14
#> [17] yaml_2.3.5 xfun_0.41 fastmap_1.1.0 withr_2.5.2
#> [21] dplyr_1.1.2 knitr_1.45 generics_0.1.3 vctrs_0.6.3
#> [25] sass_0.4.7 grid_4.2.0 tidyselect_1.2.0 glue_1.6.2
#> [29] R6_2.5.1 fansi_1.0.3 rmarkdown_2.25 farver_2.1.1
#> [33] magrittr_2.0.3 scales_1.2.1 htmltools_0.5.6.1 colorspace_2.0-3
#> [37] labeling_0.4.3 utf8_1.2.2 munsell_0.5.0 cachem_1.0.6