First of all, we need to define the number of colours that our palette will contain using this command:
- set palette maxcolors <number>
Then, what we have to do is to specify the colour of each part of the palette using the following command:
- set palette defined (<position1> "<colour1>", <position2> "<colour2>", ...)
Example (A):
- set palette maxcolors 100
- set palette defined (0 "red", 99 "blue")
We can specify as much colours as we want, for example (B):
- set palette maxcolors 1000
- set palette defined (\
- 0 "red", \
- 249 "yellow", \
- 749 "green", \
- 999 "blue")
As a final example, if we want to ascribe a specific colour to the middle value of the palette (in order, for instance, to separate positive and negative values), we will have to write something like this (C):
- set palette maxcolors 4001
- set palette defined (\
- 0 "red", \
- 1000 "orange", \
- 1600 "dark-yellow", \
- 1999 "yellow", \
- 2000 "grey", \
- 2001 "green", \
- 2400 "dark-green", \
- 3000 "cyan", \
- 4000 "blue")
Caution: The palettes presented here work in eps output files. If you work with other types of file, you may have some troubles with the colours.
One useful command is "set palette grey" (or "set palette gray" :P) that creates a palette from black to white.
ReplyDeleteAlso, "set palette maxcolors " is not necessary (but it can be useful!).
If only a color is given, gnuplot will create a gradient from black to that color.
If maxcolors is not specified, gnuplot will make gradients between the given colors.
To use more complicated colors (or "import" them from other programs) RGB hexadecimal values can be used [for instance, set palette defined (0 "#FFFFFF", 0.5 "#FFE9BF", 1 "#FFE095", 1.5 "#E8C070", 4 "#000000") ].
Also "show palette colornames" prints the defined colors with their names and RGB values.
Thank you again, ABC. I find the "show palette colornames" command particularly useful.
ReplyDelete