concept color in category gnuplot

This is an excerpt from Manning's book Gnuplot in Action.
Some material of a more specialized nature is only available in the e-book version of this book. The e-book also shows all the graphs in color. To get your free e-book in PDF, ePub, or Kindle format, go to www.manning.com/books/gnuplot-in-action-second-edition to register your print book.
Figure D.1. Adding color from a continuous palette to a surface plot. Compare figure C.1.
![]()
Let’s consider an example. Regardless of whether your input was "red" or "#ff0000" or 1 0 0, gnuplot will interpret it as follows: first channel (component A) at maximum, and the other two channels (components B and C) at minimum. If the chosen color model is RGB, then this amounts to “full red, no green or blue.” But if the chosen color model is HSV, this means “full hue, no saturation or value” (that is, black, by virtue of the zero value in the third channel). Similarly, the arguments "grey", "0xc0c0c0", and 0.75 0.75 0.75 will all be interpreted as “all three channels at three-quarters of their maximum.” In the RGB space, this amounts to a light gray; but in the HSV space, the color will be a medium purple! In every case, the input is split into its three components first, and only then are the components interpreted according to the currently active color model. (In fairness, set palette warns you if you try to use named colors with color spaces other than RGB.)
You can define a palette by specifying a set of colors at fixed locations within the plot range, and gnuplot will fill in the gaps in between. This is, in my opinion, the most useful way to create palettes in practice.
You use the defined keyword to specify the list of colors and positions. You can use any of the color formats discussed in the previous section, and hence the following four commands are equivalent:
set palette defined ( -1 "red", 0 "white", 1 "blue" ) set palette defined ( -1 "#ff0000", 0 "#ffffff", 1 "#0000ff" ) set palette defined ( -1 1 0 0, 0 1 1 1, 1 0 0 1 ) set palette defined ( -1 "red", 0 "#ffffff", 1 0 0 1 )The defined keyword must be followed by a comma-separated list in parentheses. Each of the entries between the commas consists of a position, followed by a color. Don’t get confused when using the third format (numeric triples): each entry indeed consists of four numbers, without any punctuation between them.
There’s no limit on the number of entries in the list of colors. The values used as positions aren’t restricted: they can be positive or negative, integer or floating-point. The only constraint is that they must form a non-decreasing sequence of numbers. It’s possible to repeat a position, and doing so can be useful to create palettes with sharp transitions, as we’ll discuss later. Two examples:

This is an excerpt from Manning's book Gnuplot in Action: Understanding Data with Graphs.
Palette-mapped color mode (pm3d), which makes it possible to choose colors for plots from continuous, user-defined color gradients (palettes).
The two remaining directives to the set pm3d command control the way the surface is constructed: the corners2color keyword selects how the color of each polygon is determined from the z coordinates of its four corners: as mean, median, and so on, or by choosing the value from one of the corners directly. The scansforward, scansbackward directives control the direction in which the surface is constructed. The default is scansautomatic and usually doesn’t need to be changed.
Color figure 1. The result of the test palette command for the two palettes defined by set palette model RGB defined ( 0 "red", 0.5 "yellow", 1 "green" ) (top) and set palette model RGB defined ( 0 "red", 0.1 "yellow", 1 "green" ) (bottom). The top of each graph shows the intensity levels of the red, green, and blue color components; the bottom shows the spectrum of colors and their position in the spectrum.
![]()
Color figure 2. A control chart: as the plotted value leaves the allowed region, the color of the curve changes smoothly from green to red. This graph was drawn using pm3d and the with lines palette style. See listing 9.1.
![]()
Color figure 3. A collection of sample palettes. See section 9.3.2 for details. A: linear grayscale; B: heat scale; C: standard rainbow; D: improved rainbow; E: geo scale; F: blue/white/red saturation scale; G: blue/red saturation scale with sharp transition point; H: blue/green luminance scale; J: traffic light scale for segmentation tasks; K: smooth grayscale with colored level indicators.
![]()
Color figure 4. Color renderings of a function (see section 9.4.1). Compare these graphs to the black-and-white image in figure 9.2. Note how the square symmetry comes out much more clearly in the blue/white/red graph on the top, compared to the black-and-white image, and the additional level of detail discernible in the multi-colored graph on the bottom.
![]()
Color figure 5. Color renderings of a section of the Mandelbrot set: a hue-based palette on the top and a luminance-based palette on the bottom. Note how more detail seems to be discernible in the image on the bottom, despite the wider range of colors used in the image on the top. See listing 9.3 for definitions of the palettes and figure 9.3 for a black-and-white version of this plot.
![]()
Color doesn’t reproduce well! A graph containing two lines distinguished only by their color will lose most of its values once photocopied. Similarly, offices tend to have powerful, high-speed laser printers—but they (still) usually only print black and white. There’s no guarantee that the printout somebody makes of your article containing nicely colored graphs will come out the way it looks on the screen. As my embarrassing anecdote demonstrates, about 10 percent of people are at least partially color blind. Relying on color to convey critical (as opposed to supporting) information makes your graphs inaccessible to a significant fraction of viewers. Finally, it can be difficult to read quantitative information from color. Using well-designed palettes can help, but in the end, colored graphs are great to indicate the “lay of the land” of a data set—once we reach the level of detail that we would like to study quantitative changes in data, we’re usually back to two-dimensional xy-plots.
We can let the apparent height of the surface and the local color of the surface represent different quantities. So far in this chapter, we used color only to enhance the height perception of the surface, but now we let height and color represent different quantities. This is done through an additional parameter to the using directive to the splot command: