Colortools: Color Wheel

This is the first of a series of posts about my R package colortools which I created at the end of this year’s Spring. My main motivation for creating this package was the need to have a way to generate color schemes and palettes without leaving R. You can use online resources like Color Scheme DesignerColorSchemer, Colour Lovers, and many others, but there was nothing in R for such purposes. So I saw a clear opportunity to implement some functions that allow me to get color combinations using some principles of color theory.

The Color Wheel

The starting point for generating color schemes and combining colors is the color wheel or color circle. The idea behind the color wheel is to help you choose colors in ways that they look good together. Historically, there have been many variations of the basic design, but the most popular version is a wheel of 12 colors based on the RYB (Red, Yellow, Blue) color model.

Using the package colortools you can generate color wheels for a given color with the function wheel. By default, this function will generate a color wheel with 12 colors -the basic design. However, you can set a different numbers of colors, as well as playing with different color backgrounds to see how the color is perceived as the background changes. The output of the function is the names of the colors in the wheel expressed in hexadecimal code.

Color wheel for “orange”

Let’s see how to use the wheel function with a simple example. Remember to install the package first!

# install the package

# load colortools

# default color wheel for color "orange"
wheel("orange", bg="white")

Now let’s change the background color to “steelblue”, and get a wheel with 8 colors

# another color wheel for "orange"
wheel("orange", num=8, bg="steelblue")

Colors in hexadecimal code

We can also specify the name of the color in hexadecimal code. For instance, let’s create a wheel with 20 colors for “00FFE577” and some dark grey background

# wheel for "00FFE577"
wheel("#00FFE577", num=20, bg="gray30", cex=0.8)

As you can see, the wheel function can be a very helpful tool for getting color schemes in R. Although it is one of the main functions in colortools it is not the only one: there are more functions but I will talk about them in other posts. Happy plotting!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s