Let's continue talking about Visualization Analysis and Design by diving into color. So, when we think about ways of visually encoding so far, we've been pretty focused on spatial arrangements of attributes. Now let's switch over and go beyond just spatial arrangement, and think about mapping to some of the other visual channels, particularly color. So what is going on with color? When I was talking about marks and channels before, there were these three different things that had color in them. Let's think about that. So, we need to decompose color, because the first rule of color is: don't talk about color. Specifically don't just talk about color. It's extremely confusing if we treat that as monolithic. What we really need to do is decompose this into three channels that have different characteristics. So two of these are magnitude channels that are good for ordered attributes. The luminance channel is how bright something is - think of that as grayscale black and white. And then the saturation channel is how colorful something is. So, how much pink is there in between gray and light pink and fully saturated pink. And then the third channel is an identity channel. And that's good for showing ordered attributes. So color, specifically hue, is what we usually think of as color. And so we can ask questions like what color is that? Is it red? Is it blue? Is it green? So, we've got that identity versus magnitude, and that is what helps us think about color. These channels have different properties. So what do they convey directly to the perceptual system? How much information can they convey in terms of how many discriminable bins can we use? And so we'll dive into that. So, let's talk about color channels in visualization. So, the question of whether we think of color as categorical or ordered is going to depend. We can have it either way. Right, in our upper left corner we're really focusing on the fact that there are four different years here, and those different changes of hue for 2010 versus 2013 versus 2011 distinguishes them as categories. And in contrast, in the lower left, we're much more emphasizing an order of these years, as we go from light green, to darker green, to the darkest green there is from 2010 through to 2013. And we're doing something similar on the upper right, where we've got a choropleth map, where we're using color saturation within geographic regions to color code, and then we're seeing the relationship between that and this bar chart. And we obviously have redundantly encoded the length of the bar, and the amount of green in that bar, the saturation. So we can see examples that color really can be either one of these. Now when we're thinking about categorical color, the thing that a lot of people unfortunately get wrong is, they want to encode more levels of a categorical attribute than there are available discriminable bins for categorical color. So remember that we talked a lot when we were introducing marks and channels, about the idea that human perception is completely built on relative comparisons. So that's fantastic if there's colored blocks that are next to each other. If they're contiguous, we have very high precision ability to discriminate. Here we've got a 21 chromosomes on a mouse and we're color coding. And even really subtle distinctions between greens, like in chromosomes six through nine, we're able to tell the difference when they're right next to each other. But, and here's something that's gone wrong, when they now try to map those into small and scattered regions - right here what they've done is they've said okay for a mouse chromosome where does it fall in the human chromosome - let's see how we're doing when we have these absolute comparisons of small scattered regions. Well, we've got tan, and green, brown, white, red, blue, now we're at the top of chromosome 2. Okay, light blue, purple, wait is that yellow, is that the same tan we saw before ... see a green ,is that the same green as before, maybe there's another one. So, I'm starting to, I really haven't even run out of fingers but I'm starting to lose the ability to discriminate these subtle differences in color because they're separated. And so it turns out that if you've got non-contiguous small regions of color, it's almost always fewer bins than people wish that they had available to them. So the rule of thumb is only between 6 and 12 bins can you really count on. Remembering that you need a color for the background, maybe you need a default color for something, you might need a highlight color. So in general, it's a lot fewer bins than people actually would like to use. So what can you do? Well one thing you could remember is, you don't only have color. You have other visual channels. If you do want to encode with categorical color, deliberately yourself, bin things and then map those into color. Right now what's happening is, chromosomes say 5 through 11, are all getting roughly mapped into the same bin by our eyes. It might be better if we could do a more semantic meaningful binning rather than just having the luck of the draw in terms of which things get binned involuntarily by us not being able to notice the difference. Just soIi don't only pick on the genomics folks, here's another example of people using more discriminable bins than we can really see. Notice how that light blue for cancer is pretty hard to tell apart from the light blue for ear, nose, and throat. So we really do have a limit as to the number of categories. Think carefully yourself about re: transforming your data, deriving a new categorical attribute with fewer bins if you insist on using categorical color. This is also an issue for ordered color. How many bins can we discriminate? Often not quite as many as people might like. This is a nice example from Gregor Aisch, showing how if we use the same basic idea of a choropleth map, of color coding onto geographic regions, well, what do we notice? When we just look at those legends across the top it's always quite clear what the differences are between neighboring bins. But then, when we look at the scattering of U.S. states - well great for two classes; we can definitely tell those apart. For three classes, no problem at all. For four classes, still pretty good. Now once we even start getting to five classes, it might be a little bit tricky to distinguish. Is Maine the same color as Utah?Probably? But now once we start getting to six, seven, and eight classes, it gets very difficult to tell apart when things are separate from each other. Understanding if West Virginia and Arizona are the same color with the eight class one; it's very difficult. So, remember that we have a limited number of discriminable bins if things are separated as opposed to right next to each other. The other thing we have to remember with ordered data is, everyone wants to use rainbows, but they're really a poor default. Now why is that? People get a little confused, I think, about the physics of reality, which is yes, sunlight going through a prism will scatter into a rainbow. That's a physical fact. But the biology of our eyes is not actually necessarily using that information in the way people hope. It's not intrinsic to have the ordering of the rainbow in terms of our perception. If I lock two people into separate rooms with no way to communicate, and I give them four color chips of purple, and red, and orange, and blue, are they going to put them in the same order if I ask them to do that? Probably not. I sure wouldn't bet a thousand dollars. But if I had people in rooms and I said, "Okay, what's the order in terms of if I got like a light gray, and a white, and a black, and a dark gray." Would they put them in the same order? Surely yes. So remember we want this perceptual intrinsic ordering, as opposed to anything that you have to learn. People can learn, but we want with the perceptual stuff to make sure that it's something intrinsic to the human visual system. But that's not the only problem - is the lack of intrinsic ordering - there's also a non-linearity. I'm going to say here's two regions of that spectrum and notice how within the one on the left I can go from red to orange to yellow. I can clearly see at least three different colors. And in a region of the same size i see green, green, green, on the right. Because of the way that the human eye responds to the visual spectrum it is not a linear situation. But, what are some of the benefits of rainbows? It's not that they're all bad; it's that we can actually have fine-grained structure be visible and enable. And in this picture we can talk about the red parts versus the yellow parts versus the green parts. That makes us focus on the fine grain. Now in contrast with the one on the bottom, it can actually be difficult to tell what's going on. We'll come back to that one in a minute. So let's compare a different color map for that same data set on the top. And when we just have two hues going from purple through gray into yellow we're seeing a really different sense of this dataset. We are much more able to focus on large scale structure. So, it's harder to focus on fine grain but it's easier to focus on large scale. That is then a choice of the designer. Now here we see an example where the mystery is cleared up; it's actually the coastline of Florida. And there's something else going on here there's a very carefully chosen change of hue at that zero point, to really distinguish the blues getting darker as we go down into the depths, and then the heights of the mountains. Something careful was done here. The luminance is increasing, so we do have multiple colors - but they're ordered by the luminance. So we're going from dark up to bright. So that's actually a general principle of color map design. There's some nice ones. Viridis and magma are great for sequential color, carefully designed and now deployed in many tools. And in these, the luminance is monotonically increasing. It's the hues are ordered by luminance. They have other nice properties. They're perceptually uniform. They do have multiple colors in them. And as we'll talk about later they are colorblind safe. So, these are both some useful color maps for sequential data. Let me mention one thing: rainbows are not always bad if you have categorical attributes, then you do want very, very bright colors because the ability to perceive small colors is dependent on size. So if you have little bits of color scattered around, we want saturated color. And of course the most saturated colors we can get are those rainbow colors. So if we have a segmented color map, where we're doing something categorical rather than a continuous one, then in fact rainbow colors can be very good choices. So, it all depends on matching the characteristics of your visual encoding to the characteristics of your data set, as always. So I alluded to this idea that maybe there's some interaction between channels. We really have to be careful about this with color. Color does not have separable characteristics. In particular as I mentioned, size heavily affects the salience of color. So and in particular, if you have small regions you need highly saturated colors to be able to even notice them. That's why we have highly saturated red maps on top of these larger background swaths of pale, more unsaturated, colors in the map on the left. Now if you have large regions you typically would want those to be low saturation. Notice how these big, big areas of highly saturated color really jump out at you and they're quite jarring so we want to be aware of the size as we think about the saturation to use. That can be tricky in a context where you don't know ahead of time how large a region will be if you've got, of course, a data-driven situation. So there's nuance there. Some key things to know about saturation and luminance. The most crucial is, they are not separable from each other. If you encode with one, you cannot usefully encode with the other. And moreover, they're not separable from transparency either. So these three channels of saturation, and luminance, and transparency, are all, you have to use only one of them. They they very much are not separable. Here's just an example with the same tool. And this tool, by the way, is called colorbrewer. It's a great tool for generating some color palettes that's quite informed by visualization design principles. So notice how what I've done on the left here, is I've got fully saturated colors that I've specified in the middle there, but the transparency is reasonably high. But because I've got some transparency now, these look unsaturated. And in contrast, when I have the unsaturated colors on the right, and then I have the transparency all the way, notice how I can't tell the difference. So I'm unable to tell the difference of transparency versus saturation. So, key principle; definitely keep that in mind. We're typically going to use transparency often in the design of making visual layers as we will talk about later, but we don't usually try to explicitly encode with transparency, because it is so hard to separate out from luminance and saturation. In general, if you're going to have small separated regions, the safe thing to do is to have only two bins. And, of course, remember to only use one of either saturation or luminance or transparency. Absolute max for things like saturation coding for separated regions, would be something like three to four bins. So for contiguous regions, you can have many bins if you're going to be making distinctions of things right next to each other. But, again, be careful not to try to use these three channels simultaneously. Let's talk about color palettes. Now we've already started down this, with thinking about things like categorical colors. These are all color. We're talking right now about palettes for a single attribute univariate color palettes. So we really want maximum distinguishability. That sometimes means we go for as saturated as we can, although you could also have less saturated ones. Sometimes these are called qualitative or nominal, particularly in the geographic literature if you're using tools built after that. So if you have ordered data then we really distinguish between sequential and diverging. So sequential is when you're going from min to max, and diverging is when there's some semantically meaningful midpoint. Typically we're going to use a neutral color for that, like white or yellow or gray, and then we'll pick a saturated color for each of these end points. And we see a bunch of examples of these diverging palettes - some with yellow, some with white midpoints. Now if you're doing something sequential, then we've got this ramp going from a minimum to a maximum value, where typically it's unsaturated on one side and then fully saturated or fully bright versus dark, depending on whether we're thinking about this as luminance or saturation. But those are quite hard to tell apart we want to pick just one typically. So here's a few examples of where we're doing sequential color maps, and we have multiple hues, and so we are being careful to order them by luminance as we talked about. Finally there's one more property we can think about. Remember that you can have ordered data that's cyclic, and you can emphasize the cyclic nature of that by having many hues. So multi-hue maps are useful for trying to show the cyclic nature of the data. So the design considerations for a color palette for a single attribute are, first of all, are we looking at segmented discrete little boxes, or something that's continuous? Are we looking at diverging or sequential or cyclic as the properties of the data set we want to emphasize? Do we have one hue or two hues or multiple hues? Is it perceptually linear? And have we ordered the hues by luminance? And as we'll get to later, is it colorblind safe? Well, we had been talking about color for one attribute. What if we want to encode two different attributes with color? These are what's called bivariate color maps. Now there is a straightforward case where we have two different attributes, but one of those attributes is binary. It's just on or off. So here's an example of that where essentially we've got a variation in hue, and then we have the low saturation and the high saturation version of that. So what's getting encoded with saturation is just binary on or off. People are reasonably able to deal with those. But in the cases where you actually have multiple levels in each of two different attributes, it gets very tricky people do use these sometimes, but there's a fair amount of empirical evidence that people find them difficult to interpret. Not impossible, but certainly difficult. So be aware that it is a much more tricky design problem to have bivariate color maps with multiple levels in each of the directions as opposed to just binary in one of those directions.