next up previous contents index
Next: Colorspec Up: Gnuplot Previous: Glossary   Contents   Index


Linetype, colors, and styles

Each gnuplot terminal type provides a set of distinct "linetypes". These may differ in color, in thickness, in dot/dash pattern, or in some combination of color and dot/dash. The default linetypes for a particular terminal can be previewed by issuing the test command after setting the terminal type. The pre-defined colors and dot/dash patterns are not guaranteed to be consistent for all terminal types, but all terminals use the special linetype -1 to mean a solid line in the primary foreground color (normally black). By default, successive functions or datafiles plotted by a single command will be assigned successive linetypes. You can override this default by specifying a particular linetype for any function, datafile, or plot element.

Examples:


    plot "foo", "bar"                 # plot two files using linetypes 1, 2
    plot sin(x) linetype 4            # terminal-specific linetype color 4
    plot sin(x) lt -1                 # black

For many terminal types it is also possible to assign user-defined colors using explicit rgb (red, green, blue) values, named colors, or color values that refer to the current PM3D palette.

Examples:


    plot sin(x) lt rgb "violet"       # one of gnuplot's named colors
    plot sin(x) lt rgb "#FF00FF"      # explicit RGB triple in hexadecimal
    plot sin(x) lt palette cb -45     # whatever color corresponds to -45
                                      # in the current cbrange of the palette
    plot sin(x) lt palette frac 0.3   # fractional value along the palette

See show palette colornames (p. [*]), set palette (p. [*]), cbrange (p. [*]).

For terminals that support dot/dash patterns, each default linetype has both a dot-dash pattern and a default color. However, you can override the default color by using the keyword linecolor, abbreviated lc. For example, the postscript terminal provides a dashed blue line as linetype 3. The plot commands below use this same dash pattern for three plots, one in blue (the default), another in red (the default for linetype 1), and a third in gold.

Example:


    set term postscript dashed color
    plot 'foo' lt 3, 'baz' lt 3 linecolor 1, 'bar' lt 3 lc rgb 'gold'

Lines can have additional properties such as linewidth. You can associate these various properties, as well as equivalent properties for point symbols, into user-defined "line styles" using the command set style line. Once you have defined a linestyle, you can use it in a plot command to control the appearance of one or more plot elements.

Examples:


    # define a new line style with terminal-independent color cyan,
    # linewidth 3, and associated point type 6 (a circle with a dot in it).
    set style line 5 lt rgb "cyan" lw 3 pt 6
    plot sin(x) with linespoints ls 5          # user-defined line style 5

See linestyle (p. [*]), set style line (p. [*]).


Subsections
next up previous contents index
Next: Colorspec Up: Gnuplot Previous: Glossary   Contents   Index
Ethan Merritt 2007-03-03