Title: | Profinit Plotting Theme |
---|---|
Description: | Help unify visual output of R analyses in the Profinit EU company. So far, there are color and fill scales for 'ggplot2', plotting theme for 'ggplot2', color palettes and utils to make the tools default choices. |
Authors: | Dominik Matula [aut, cre], Profinit EU, Ltd. [cph, fnd] |
Maintainer: | Dominik Matula <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.3 |
Built: | 2025-03-12 03:47:10 UTC |
Source: | https://github.com/cran/profiplots |
This function provides an access to standardized Profinit colors hex codes.
profinit_cols(..., named = FALSE)
profinit_cols(..., named = FALSE)
... |
Either character name(s) or order of Profinit colors. Leave empty for the full color set. |
named |
Flag whether to produce named vector of profinit colours.
Defautls to |
Named character vector the same length as input params.
# to get Profinit red hexcode profinit_cols("red") # to get Profinit red and gray hexcodes profinit_cols("red", "grey") # to get the first Profinit color profinit_cols(1) # to get all Profinit colors profinit_cols() scales::show_col(profinit_cols())
# to get Profinit red hexcode profinit_cols("red") # to get Profinit red and gray hexcodes profinit_cols("red", "grey") # to get the first Profinit color profinit_cols(1) # to get all Profinit colors profinit_cols() scales::show_col(profinit_cols())
Returns function that interpolates (if exact=FALSE
) chosen Profinit color palette.
That is, the resulting function is able to give you desired number
of colors (hexes) within given Profinit color palette.
profinit_pal(pal_name = "blue-red", reverse = FALSE, exact = NULL, ...)
profinit_pal(pal_name = "blue-red", reverse = FALSE, exact = NULL, ...)
pal_name |
Character name of chosen Profinit palette. See |
reverse |
Boolean indicating whether the palette should be reversed |
exact |
Indicates whether the color scale is supposed to be followed exactly.
Be ware you may run out of colors. Defaults to |
... |
Additional arguments to pass to |
See the examples for more details about its usecase.
A function providing desired number of colors (hex codes) from the specified palette.
# Example 1 - get colors from the 'discrete' Profinit palette discrete_cols <- profinit_pal("discrete") discrete_cols(3) scales::show_col(discrete_cols(3)) # .. The number of colors is limited in this palette. Once you reach the # limit, Profinit's grey is used to fill the missings: scales::show_col(discrete_cols(10)) # .. You can bypass this via either enabling the interpolation (defaults # to `FALSE` for `discrete`-like color palettes and `TRUE` for other palettes) # or try your luck with full set of Profinit colors. discrete_cols_int <- profinit_pal("discrete", exact = FALSE) scales::show_col(discrete_cols_int(10)) # Example 2 - get colors from other Profinit palette profinit_reds_cols <- profinit_pal("reds") profinit_reds_cols(3) scales::show_col(profinit_reds_cols(3)) # Again, we can interpolate profinit_reds_cols(15) scales::show_col(profinit_reds_cols(15)) # Example 3 - using palette in baseR plots plot(mtcars$mpg, mtcars$qsec, col=profinit_pal("discrete")(5), pch=16)
# Example 1 - get colors from the 'discrete' Profinit palette discrete_cols <- profinit_pal("discrete") discrete_cols(3) scales::show_col(discrete_cols(3)) # .. The number of colors is limited in this palette. Once you reach the # limit, Profinit's grey is used to fill the missings: scales::show_col(discrete_cols(10)) # .. You can bypass this via either enabling the interpolation (defaults # to `FALSE` for `discrete`-like color palettes and `TRUE` for other palettes) # or try your luck with full set of Profinit colors. discrete_cols_int <- profinit_pal("discrete", exact = FALSE) scales::show_col(discrete_cols_int(10)) # Example 2 - get colors from other Profinit palette profinit_reds_cols <- profinit_pal("reds") profinit_reds_cols(3) scales::show_col(profinit_reds_cols(3)) # Again, we can interpolate profinit_reds_cols(15) scales::show_col(profinit_reds_cols(15)) # Example 3 - using palette in baseR plots plot(mtcars$mpg, mtcars$qsec, col=profinit_pal("discrete")(5), pch=16)
Note: Function name has been chosen to match the grDevices::palette.pals()
.
profinit_pal.pals()
profinit_pal.pals()
A character vector of all available palettes in this package.
profinit_pal.pals() # Now you are able to use this information, e.g.: reds_palette <- profinit_pal("reds") reds_palette(4) scales::show_col(reds_palette(4))
profinit_pal.pals() # Now you are able to use this information, e.g.: reds_palette <- profinit_pal("reds") reds_palette(4) scales::show_col(reds_palette(4))
Profinit color scale constructor
scale_color_profinit_d
- Discrete Profinit color scale (similar to
scale_color_viridis_d
). It can't be used with continuous variables. There
is BrE equivalent, too: scale_colour_profinit_d
.
scale_color_profinit_c
- Continuous Profinit color scale (similar to
scale_color_viridis_c
). It can't be used with discrete variables. There is
BrE equivalent, too: scale_colour_profinit_c
.
scale_color_profinit( palette = "blue-red", discrete = TRUE, reverse = FALSE, exact = NULL, na.value = NULL, ... ) scale_colour_profinit( palette = "blue-red", discrete = TRUE, reverse = FALSE, exact = NULL, na.value = NULL, ... ) scale_color_profinit_d(palette = "blue-red", ...) scale_colour_profinit_d(palette = "blue-red", ...) scale_color_profinit_c(palette = "blue-red", ...) scale_colour_profinit_c(palette = "blue-red", ...)
scale_color_profinit( palette = "blue-red", discrete = TRUE, reverse = FALSE, exact = NULL, na.value = NULL, ... ) scale_colour_profinit( palette = "blue-red", discrete = TRUE, reverse = FALSE, exact = NULL, na.value = NULL, ... ) scale_color_profinit_d(palette = "blue-red", ...) scale_colour_profinit_d(palette = "blue-red", ...) scale_color_profinit_c(palette = "blue-red", ...) scale_colour_profinit_c(palette = "blue-red", ...)
palette |
Character name of palette in |
discrete |
Boolean indicating whether color aesthetic is discrete or not. Defaults to |
reverse |
Boolean indicating whether the palette should be reversed. Defaults to |
exact |
Indicates whether the color scale is supposed to be followed exactly.
Be ware you may run out of colors. Defaults to |
na.value |
What value is going to be used for missings. Defaults to profinit's grey with some transparency added. |
... |
Additional arguments passed to |
Ggplot2 color scale constructor based on Profinit color palette.
library(ggplot2) iris_plt <- ggplot(iris, aes(x = Sepal.Width, y = Sepal.Length, color = Species)) + geom_point() + theme_profinit() iris_plt + scale_color_profinit() # Now, let's use another Profinit palette: # (see `profinit_pal.pals()` for all the options) iris_plt + scale_color_profinit(palette = "reds-dark")
library(ggplot2) iris_plt <- ggplot(iris, aes(x = Sepal.Width, y = Sepal.Length, color = Species)) + geom_point() + theme_profinit() iris_plt + scale_color_profinit() # Now, let's use another Profinit palette: # (see `profinit_pal.pals()` for all the options) iris_plt + scale_color_profinit(palette = "reds-dark")
Fill scale constructor for Profinit colors.
scale_fill_profinit_d
- Discrete Profinit fill scale (similar to
scale_fill_viridis_d
). It can't be used with continuous variables.
scale_fill_profinit_c
- Continuous Profinit fill scale (similar to
scale_fill_viridis_c
). It can't be used with discrete variables.
scale_fill_profinit( palette = "blue-red", discrete = TRUE, reverse = FALSE, exact = NULL, ... ) scale_fill_profinit_d(palette = "blue-red", ...) scale_fill_profinit_c(palette = "blue-red", ...)
scale_fill_profinit( palette = "blue-red", discrete = TRUE, reverse = FALSE, exact = NULL, ... ) scale_fill_profinit_d(palette = "blue-red", ...) scale_fill_profinit_c(palette = "blue-red", ...)
palette |
Character name of palette in |
discrete |
Boolean, indicating whether color aesthetic is discrete or not |
reverse |
Boolean, indicating whether the palette should be reversed |
exact |
Indicates whether the color scale is supposed to be followed exactly.
Be ware, you may run out of colors. Defaults to |
... |
Additional arguments passed to |
Ggplot2 fill scale constructor based on Profinit color palette.
library(ggplot2) plt <- ggplot(ggplot2::diamonds, ggplot2::aes(x = clarity, y = price, fill = clarity)) + geom_boxplot() + theme_profinit() plt + scale_fill_profinit() # Discrete scale, follow exact color codes (default for the `discrete` palette). # ! You may run out of colors - see the example below. # Use either exact = FALSE (next example) or `discrete-full` palette. plt + scale_fill_profinit("discrete") # Now, the colors are approximated plt + scale_fill_profinit("discrete", exact = FALSE)
library(ggplot2) plt <- ggplot(ggplot2::diamonds, ggplot2::aes(x = clarity, y = price, fill = clarity)) + geom_boxplot() + theme_profinit() plt + scale_fill_profinit() # Discrete scale, follow exact color codes (default for the `discrete` palette). # ! You may run out of colors - see the example below. # Use either exact = FALSE (next example) or `discrete-full` palette. plt + scale_fill_profinit("discrete") # Now, the colors are approximated plt + scale_fill_profinit("discrete", exact = FALSE)
This function alternates the default graphics behavior (both, base R graphics and ggplot2 graphics) to follow Profinit visual guide. Be were, the recent setup is not stored anywhere before changing the values.
The function sets to defaults color and fill scales in ggplot2, R4 color palette (base graphics) and greyish color theme in ggplot2.
set_theme(pal_name = "blue-red", pal_name_discrete = "discrete", exact = NULL) unset_theme()
set_theme(pal_name = "blue-red", pal_name_discrete = "discrete", exact = NULL) unset_theme()
pal_name |
Profinit palette name to be used. Defaults to |
pal_name_discrete |
(Optional). Palette name for discrete color scales to be used by |
exact |
Indicates whether discrete values will be treated exactly as present in the palette OR whether and interpolation can take a place. |
The function returns nothing, it edits default behavior. Recent default configs are stored in a backup option.
The function returns nothing, it just changes default behaviour.
set_theme()
: Sets default plotting theme to Profinit.
unset_theme()
: Resets default plotting theme.
# Example 1 - BaseR # As a starting point, there is a plot i base R graphic: sample_df <- data.frame(x=1:8, y=1:8, category=as.character(1:8), col_cont = 1:8) barplot(sample_df$y, col=sample_df$category) # Now, by applying hte set_theme() we can change the default behavior: profiplots::set_theme("blue-red", "blue-red") barplot(sample_df$y, col=sample_df$category) # To turn the theming off, just call: profiplots::unset_theme() # Example 2 - GGplot library("ggplot2") plot_gg <- ggplot(sample_df, aes(x=x, y=y, fill=category)) + stat_identity(geom="bar") plot_gg # Now, let's trun it into Profinit graphics. profiplots::set_theme("blue-red", "blue-red") plot_gg # To remove the Profinit theme from defaults, just call: profiplots::unset_theme()
# Example 1 - BaseR # As a starting point, there is a plot i base R graphic: sample_df <- data.frame(x=1:8, y=1:8, category=as.character(1:8), col_cont = 1:8) barplot(sample_df$y, col=sample_df$category) # Now, by applying hte set_theme() we can change the default behavior: profiplots::set_theme("blue-red", "blue-red") barplot(sample_df$y, col=sample_df$category) # To turn the theming off, just call: profiplots::unset_theme() # Example 2 - GGplot library("ggplot2") plot_gg <- ggplot(sample_df, aes(x=x, y=y, fill=category)) + stat_identity(geom="bar") plot_gg # Now, let's trun it into Profinit graphics. profiplots::set_theme("blue-red", "blue-red") plot_gg # To remove the Profinit theme from defaults, just call: profiplots::unset_theme()
The current version of the theme is based on ggplot2::theme_minimal()
not
tweaking any of its settings. Later on, the theme will be customised to
better fill our needs and preferences.
theme_profinit()
theme_profinit()
Ggplot2's theme object adjusted according to Profinit's preferences.
scale_fill_profinit and scale_color_profinit for Profinit color scales.
# default behavior library(ggplot2) iris_plt <- ggplot(iris, aes(x=Sepal.Length, fill=Species)) + geom_density(alpha=.5) + scale_fill_profinit() iris_plt # With profinit theme iris_plt + theme_profinit()
# default behavior library(ggplot2) iris_plt <- ggplot(iris, aes(x=Sepal.Length, fill=Species)) + geom_density(alpha=.5) + scale_fill_profinit() iris_plt # With profinit theme iris_plt + theme_profinit()