Although IBCS recommend to use
gray colors for plotting, tidycharts
enables user to define
their color palette. The same applies to styles, the default IBCS are
implemented, but there is a way to set one’s own styles. In this
vignette we will show how to customize the package.
Firstly, we need to define a data frame with 6 rows and 2 columns.
Column bar_colors
contains 6 colors which will be used to
draw the bars. Column text_colors
contains color of labels
that will be drawn on bars. Ideally, text_colors
are
contrasting to corresponding row of bar_colors
. Users with
a lack of the sense of aesthetics are encouraged to select color palette
with a help of dedicated software :
color_df <- data.frame(
bar_colors = c("rgb(61, 56, 124)",
"rgb(0,89,161)",
"rgb(0,120,186)",
"rgb(0,150,193)",
"rgb(0, 178, 184)",
"rgb(0,178,184)"),
text_colors = c("white",
"white",
"white",
"white",
"white",
"black")
)
Then, we use set_colors
function from
tidycharts
package.
Now, we can generate chart using new palette.
Styles are used to indicate different type of presented data.
actual
, previous
, plan
,
forecast
styles are implemented out of the box.
When defining styles, one must define stroke
and
fill
parameters as column names. Style names are
unrestricted. Use set_styles
to bind styles_df
to the package environment.
styles_df <- rbind(
actual = list(fill = "rgb(64,64,64)", stroke = "rgb(64,64,64)" ),
fictual = list(fill = "rgb(221,28,119)", stroke = "rgb(136,86,167)")
)
set_styles(styles_df)
Now, refer to styles through given names and use them in chart functions.