Determine Transparent Hex Code of Color in R (Example Code)

In this R article you’ll learn how to determine the transparent version of a hex color code.

Setting up the Example

example_color <- "purple"                          # Specify color
install.packages("scales")                         # Install scales package
library("scales")                                  # Load scales
show_col(example_color)                            # Display color in RStudio

r graph figure 1 determine transparent hex code color r

Example: Get Transparent Version of Color

example_color_alpha <- adjustcolor(example_color,  # Applying adjustcolor()
                                   alpha.f = 0.3)
example_color_alpha                                # Display hex color code in RStudio console
# [1] "#A020F04D"
show_col(c(example_color,                          # Display original & new colors in RStudio
           example_color_alpha))

r graph figure 2 determine transparent hex code color r

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top