7.6 Highlighting an Item

7.6.1 Problem

You want to change the color of an item to make it stand out.

7.6.2 Solution

To highlight one or more items, create a new column in the data and map it to the color. In this example, we’ll create a copy of the PlantGrowth data set called pg_mod and create a new column, hl, which is set to no if the case was in the control group or treatment 1 group, and set to yes if the case was in the treatment 2 group:

Then we’ll plot this data with specified colors, and hiding the legend (Figure 7.13):

Highlighting one item

Figure 7.13: Highlighting one item

7.6.3 Discussion

If you have a small number of items, as in this example, instead of creating a new column you could use the original one and specify the colors for every level of that variable. For example, the following code will use the group column from PlantGrowth and manually set the colors for each of the three levels. The result will appear the same as with the preceding code:

7.6.4 See Also

See Chapter 12 for more information about specifying colors.

For more information about removing the legend, see Recipe 10.1.