The Technicalities of Color

The Technicalities of Color

When we create graphics like data visualizations, color choice is one way we can impactfully communicate our insights. On the surface, colors might look deceivingly easy, but there's incredible science behind how they work.

Color Models (RGB and CMYK)

For those who create visuals in Excel, Power BI, Python, or R (to name a few), you're probably already familiar with the color options that we can easily select from or insert directly as parameters into our code. Instead of talking about the creative color names available in the Python or R color palettes in this newsletter, we're going to talk instead about how colors work behind the scenes. There are two common color models that designers use: RGB and CMYK.

No alt text provided for this image

RGB

The acronym RGB stands for Red-Green-Blue. We commonly see this additive color model in digital design where the screen is black unless we add colors to it. We see white on the screen when the RGB color model combines all the primary colors together. Each of the color values for red, green, and blue in the RGB model range from 0 to 255. The single color we see depends on the combination of each of these values.

No alt text provided for this image

Notice the combination of RGB values it takes to create the ten default Excel colors plus white and black. We can also see that white has RGB values of 255 across the board, while the values for black are all 0 because it represents the absence of light.

We'll often see RGB colors denoted by hex values, which represent shorthand notation of RGB values in hexadecimal format.

  • Excel has a function, DEC2HEX, that converts a number into a hexadecimal value. We can see the numbers between 0 and 255 represented as hexadecimal values on the left below.
  • Notice how the hexadecimal values have the order 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F instead of 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, which means they use a base of 16 instead of 10.
  • We can calculate the hexadecimal number for each of the RGB values, but also notice that the DEC2HEX function has two input parameters. The first is the number we're converting. The second parameter is the number of places we want our hexadecimal value output to display. Because we want to ultimately calculate hexadecimal values with six characters plus the hash sign, we put 2 into this parameter so it returns 0F instead of F for example.
  • The format for a hex value starts with a hash sign # concatenated together with the rest of the RGB values as a single string. In the formula bar, we see that the calculation for the hex value given the existing RGB values is a combination of concatenation using characters, ampersands, and DEC2HEX function.

No alt text provided for this image

For each Power BI model that I develop and ultimately publish, I'm very mindful of the colors I choose to use it in. I'll often extract colors from an organization's logo for example using the color tools available online through Adobe. One way to save the hex value color selections to use in multiple Power BI models is by creating a report theme to import directly into Power BI, which I cover in the video below in my Data Dashboards for Power BI course in the LinkedIn Learning library.

CMYK

The acronym CMYK stands for Cyan-Magenta-Yellow-Key, where Key typically displays as black. We often see this color model in printed design materials because it's a subtractive model where white represents the color of the paper in the background, where we see black when we combine all the colors together. Because I work mostly in the digital space with data science and business intelligence models that others normally view on a screen, I typically use the RGB color model, but I think it's fascinating to think about both these common color models in the context of each other.

Here's how to estimate the conversion of Excel colors from hex values to RGB to CMYK. Notice that while the Key value (represented as black) is the last letter in the acronym, it's actually the first percentage we calculate in converting the RGB color model to CMYK. We can then calculate the cyan, magenta, and yellow percentages once we know the black percentage in the CMYK color model.

No alt text provided for this image

Color Blindness

The human eye sees color in a way that's much like the RGB color model. The eye has three cones that serve as photoreceptor cells in the retina to see different wavelengths of light. The short (S), medium (M), and long (L) cones respond to colors depending on their wavelength as we can see below.

No alt text provided for this image

User accessibility in technology is an important topic that's finally getting the traction it deserves and needs in discussions about products that so many people use. We want to make our work useful for not only us, but others who might be end users of the work we do. One way to improve user accessibility is by choosing colors that account for color blindness, a condition which impacts an estimated 5-10% of the population.

We can see that with normal vision, there's minimal overlap between the red and green cones in the eye. The most common kind of color blindness is the inability to distinguish between red and green because there's a significant overlap between the red and green cones.

No alt text provided for this image

Those with color blindness might see brown instead of distinct shades of green and red, which means these two colors can cause problems if we use them together in the same visual. So, what colors will work then? We can take the colors we want to use and see what they look like to those with color blindness as a starting point. Using the same default Excel colors, we can see that while green and red can pose problems for color user accessibility, blue and orange look pretty different for almost all types of color blindness. My own default choice of colors (especially for a color scale) is orange, blue, and gray.

No alt text provided for this image

Color models and color user accessibility are two topics within the vast and fascinating space of how colors work. I'm looking forward to learning more about colors when I get a chance to read Color Appearance Models by Mark Fairchild.

I'm excited to share that my Power BI Weekly series comes out tomorrow with a new video coming out each week on Thursday. First up in the series: how to properly account for Daylight Savings Time in Power BI models. I'll post the video when it comes out and also share it in next week's newsletter - stay tuned!

-HW

Helen Wall

LinkedIn [in]structor | Data Science Consulting

2 年

Update: I added another graphic to this newsletter edition for the calculations of the hex values from RGB!

Karen Amick

Manager Financial Planning | Analyzing Financial Performance | Identifying Cost Saving Opportunities | Collaborative Problem Solver | Passionate about Driving Effciency & Growth

2 年

Very interesting!

Leidy Napijalo

Head of Operations and Corporate Investment | Ingeniería eléctrica y electrónica

2 年

I have to be honest, I have been waiting this haha like for a year. Thank you so much this Is extremely helpful and I love to read your content, it has helped me a lot ??

Scott Helmers

Visio expert | Business process consultant | Dynamic speaker and instructor | LinkedIn Learning Instructor | Book author | Educator at heart

2 年

Courtesy of a referral from my nephew who is a UX designer, I've been using Adobe's accessible color palette generator https://color.adobe.com/create/color-accessibility. It lets you generate palettes of five colors that are differentiable for people with the three most common types of color blindness. And it's kind of fun to play with!

要查看或添加评论,请登录

Helen Wall的更多文章

  • Flying on Autopilot

    Flying on Autopilot

    I remember taking a plane flight several years ago with a roller coaster landing. It was an otherwise uneventful short…

    2 条评论
  • Releasing Snakes into the Wild

    Releasing Snakes into the Wild

    This week brings big news in both the Excel and Python communities! Python in Excel is now generally available as of…

    4 条评论
  • Slithering Back In

    Slithering Back In

    I'm finally catching up on the latest editions of my newsletter after a bit of a break. Writing newsletters or any kind…

    2 条评论
  • The Modern Updates

    The Modern Updates

    As I was perusing potential updates for my home recently, I started to think about how the definition of "modern" will…

  • WINDOWs of the World

    WINDOWs of the World

    It's really hard to get very far in data science without knowing SQL. Within SQL there are different levels of…

    3 条评论
  • Straightening Things Out

    Straightening Things Out

    When I took linear algebra in college, my favorite part of the class was the end of it. The course was highly…

    2 条评论
  • SWITCH It Up

    SWITCH It Up

    In order to master managing data models, learning how to leverage conditional logic is a must. We see conditional logic…

    3 条评论
  • Seeing Dots

    Seeing Dots

    I use data visualizations not only to communicate data models to end-users who are stakeholders, but I also personally…

    5 条评论
  • The Digital Rolodex

    The Digital Rolodex

    A few months ago, I was doing my civic duty as part of a potential jury panel. While we were waiting for the court to…

    4 条评论
  • Making the "Old" New

    Making the "Old" New

    I talk with a lot of people about whether their organization uses custom visuals in Power BI. Their answers often vary…

    4 条评论

社区洞察

其他会员也浏览了