colorstyle — Choices for color 5
CMYK values
In addition to mixing your own colors by using RGB values, you can mix your own colors by
using CMYK values. If you have not heard of CMYK values or been asked to produce CMYK color
separations, you can safely skip this section. CMYK is provided primarily to assist those doing color
separations for mass printings. Although most inkjet printers use the more common RGB color values,
printing presses almost always require CMYK values for color separation.
RGB values represent a mixing of red, green, and blue light, whereas CMYK values represent a
mixing of pigments—cyan, magenta, yellow, and black. Thus, as the numbers get bigger, RGB colors
go from dark to bright, whereas the CMYK colors go from light to dark.
CMYK values can be specified either as integers from 0 to 255, or as proportions of ink using real
numbers from 0.0 to 1.0. If all four values are 1 or less, the numbers are taken to be proportions of
ink. Thus, 127 0 127 0 and 0.5 0 0.5 0 specify almost equivalent colors.
Some examples of CMYK colors are
red = 0 255 255 0 or, equivalently, 0 1 1 0
green = 255 0 255 0 or, equivalently, 1 0 1 0
blue = 255 255 0 0 or, equivalently, 1 1 0 0
cyan = 255 0 0 0 or, equivalently, 1 0 0 0
magenta = 0 255 0 0 or, equivalently, 0 1 0 0
yellow = 0 0 255 0 or, equivalently, 0 0 1 0
white = 0 0 0 0 or, equivalently, 0 0 0 0
black = 0 0 0 255 or, equivalently, 0 0 0 1
For color representation, there is no reason for the K (black) component of the CMYK values, 255
255 255 0 and 0 0 0 255 both specify the color black. With pigments such as printer inks, however,
using 100% of cyan, magenta, and yellow rarely produces a pure black. For that reason, CMYK values
include a specific black component.
Internally, Stata stores all colors as RGB values, even when CMYK values are specified. This allows
colors to be easily shown on most display devices. In fact, graph export will produce graph files
using RGB values, even when CMYK values were specified as input. Only a few devices and graphics
formats understand CMYK colors, with PostScript and EPS formats being two of the most important.
To obtain CMYK colors in these formats, use the cmyk(on) option of the graph export command.
You can also specify that all PostScript export files permanently use CMYK colors with the command
translator set Graph2ps cmyk on or translator set Graph2eps cmyk on for EPS files.
Stata uses, for lack of a better term, normalized CMYK values. That simply means that at least
one of the CMY values is normalized to 0 for all CMYK colors, with the K (black) value “absorbing”
all parts of CM and Y where they are all positive. An example may help: 10 10 5 0 is taken to be
the normalized CMYK value 5 5 0 5. That is, all CMY colors were 5 or greater, so this component
was moved to black ink, and 5 was subtracted from each of the CMY values. If you specify your
CMYK colors in normalized form, these will be exactly the values output by graph export, and you
should never be surprised by the resulting colors.
HSV values
You can also mix your own colors by specifying HSV values. These are also sometimes called HSL
(hue, saturation, and luminance) or HSB (hue, saturation, and brightness). An HSV value is a triplet
of numbers. The first number specifies the hue and is specified on a circular 360-degree scale. Any
number can be specified for the hue, but numbers above 360 are taken as modulo 360. The second
number specifies the saturation of the color as a proportion between 0 and 1, and the third number
specifies the value (luminance/brightness) between 0 and 1. HSV colors must be prefaced with hsv.