tikz.dev / PGFplots Manual

Manual for Package pgfplots
2D/3D Plots in LA, Version 1.18.1
http://sourceforge.net/projects/pgfplots

Related Libraries

\(\newcommand{\footnotename}{footnote}\) \(\def \LWRfootnote {1}\) \(\newcommand {\footnote }[2][\LWRfootnote ]{{}^{\mathrm {#1}}}\) \(\newcommand {\footnotemark }[1][\LWRfootnote ]{{}^{\mathrm {#1}}}\) \(\let \LWRorighspace \hspace \) \(\renewcommand {\hspace }{\ifstar \LWRorighspace \LWRorighspace }\) \(\newcommand {\mathnormal }[1]{{#1}}\) \(\newcommand \ensuremath [1]{#1}\) \(\newcommand {\LWRframebox }[2][]{\fbox {#2}} \newcommand {\framebox }[1][]{\LWRframebox } \) \(\newcommand {\setlength }[2]{}\) \(\newcommand {\addtolength }[2]{}\) \(\newcommand {\setcounter }[2]{}\) \(\newcommand {\addtocounter }[2]{}\) \(\newcommand {\arabic }[1]{}\) \(\newcommand {\number }[1]{}\) \(\newcommand {\noalign }[1]{\text {#1}\notag \\}\) \(\newcommand {\cline }[1]{}\) \(\newcommand {\directlua }[1]{\text {(directlua)}}\) \(\newcommand {\luatexdirectlua }[1]{\text {(directlua)}}\) \(\newcommand {\protect }{}\) \(\def \LWRabsorbnumber #1 {}\) \(\def \LWRabsorbquotenumber "#1 {}\) \(\newcommand {\LWRabsorboption }[1][]{}\) \(\newcommand {\LWRabsorbtwooptions }[1][]{\LWRabsorboption }\) \(\def \mathchar {\ifnextchar "\LWRabsorbquotenumber \LWRabsorbnumber }\) \(\def \mathcode #1={\mathchar }\) \(\let \delcode \mathcode \) \(\let \delimiter \mathchar \) \(\def \oe {\unicode {x0153}}\) \(\def \OE {\unicode {x0152}}\) \(\def \ae {\unicode {x00E6}}\) \(\def \AE {\unicode {x00C6}}\) \(\def \aa {\unicode {x00E5}}\) \(\def \AA {\unicode {x00C5}}\) \(\def \o {\unicode {x00F8}}\) \(\def \O {\unicode {x00D8}}\) \(\def \l {\unicode {x0142}}\) \(\def \L {\unicode {x0141}}\) \(\def \ss {\unicode {x00DF}}\) \(\def \SS {\unicode {x1E9E}}\) \(\def \dag {\unicode {x2020}}\) \(\def \ddag {\unicode {x2021}}\) \(\def \P {\unicode {x00B6}}\) \(\def \copyright {\unicode {x00A9}}\) \(\def \pounds {\unicode {x00A3}}\) \(\let \LWRref \ref \) \(\renewcommand {\ref }{\ifstar \LWRref \LWRref }\) \( \newcommand {\multicolumn }[3]{#3}\) \(\require {textcomp}\) \( \newcommand {\meta }[1]{\langle \textit {#1}\rangle } \) \(\newcommand {\toprule }[1][]{\hline }\) \(\let \midrule \toprule \) \(\let \bottomrule \toprule \) \(\def \LWRbooktabscmidruleparen (#1)#2{}\) \(\newcommand {\LWRbooktabscmidrulenoparen }[1]{}\) \(\newcommand {\cmidrule }[1][]{\ifnextchar (\LWRbooktabscmidruleparen \LWRbooktabscmidrulenoparen }\) \(\newcommand {\morecmidrules }{}\) \(\newcommand {\specialrule }[3]{\hline }\) \(\newcommand {\addlinespace }[1][]{}\) \(\require {colortbl}\) \(\let \LWRorigcolumncolor \columncolor \) \(\renewcommand {\columncolor }[2][named]{\LWRorigcolumncolor [#1]{#2}\LWRabsorbtwooptions }\) \(\let \LWRorigrowcolor \rowcolor \) \(\renewcommand {\rowcolor }[2][named]{\LWRorigrowcolor [#1]{#2}\LWRabsorbtwooptions }\) \(\let \LWRorigcellcolor \cellcolor \) \(\renewcommand {\cellcolor }[2][named]{\LWRorigcellcolor [#1]{#2}\LWRabsorbtwooptions }\) \(\newcommand {\intertext }[1]{\text {#1}\notag \\}\) \(\let \Hat \hat \) \(\let \Check \check \) \(\let \Tilde \tilde \) \(\let \Acute \acute \) \(\let \Grave \grave \) \(\let \Dot \dot \) \(\let \Ddot \ddot \) \(\let \Breve \breve \) \(\let \Bar \bar \) \(\let \Vec \vec \) \(\newcommand {\nicefrac }[3][]{\mathinner {{}^{#2}\!/\!_{#3}}}\)

5.2ColorBrewer

An extension by Vincent A. Traag and Stefan Pinnow

  • \usepgfplotslibrary{colorbrewer} % and plain

  • \usepgfplotslibrary[colorbrewer] % Cont

  • \usetikzlibrary{pgfplots.colorbrewer} % and plain

  • \usetikzlibrary[pgfplots.colorbrewer] % Cont

  • This library brings the color schemes created by Cynthia Brewer published at http://colorbrewer2.org/ to PGFPlots. These where originally designed for cartography needs, but are also used in other kind of data visualization in the mean time. The ColorBrewer schemes are divided into the types

    sequential

    for ordered data progressing from low to high,

    diverging

    to highlight changes from a mean value, and

    qualitative

    where colors have no special order.

    They can consist of up to 12 different data classes, i.e. colors, per scheme and are provided as color maps as well as as cycle lists.

    .
    (-tikz- diagram) (-tikz- diagram)
    (-tikz- diagram) (-tikz- diagram)
    (-tikz- diagram) (-tikz- diagram)
5.2.1Usage

In the following the available schemes are presented in graphical form as “swatches”.

Color Schemes as “Swatches”

A swatch is a matrix showing all available colors for a specific scheme, and the available color compilations.

(-tikz- diagram)

Such swatches are read as follows:

  • 1. At the top left of the block you find the (short) name of the scheme.

  • 2. The following color blocks are the colors the scheme consists of.

  • 3. To get the (full) color name, combine the (short) scheme name with a hyphen and a letter of the first row, e.g.

    \tikz \fill[color=GnBu-H] (0,0) rectangle (1em,2ex);

    which results in (-tikz- diagram).

  • 4. To get the full scheme name, which can be used as colormap or cycle list, combine the (short) scheme name with a hyphen and a number of the first column, e.g. cycle list name=GnBu-7.
    The special case of using the (short) scheme name only is also provided and is an alias for the full scheme name with the highest number, e.g. scheme name GnBu equals GnBu-9.

  • 5. The last row shows a continuous color map based on the previous row, that is in the example GnBu-9.

  • 6. The rest of the matrix shows the colors used in the corresponding scheme.

Activating Color Schemes

In order to activate a colorbrewer colormap, say, BuGn-5, you have to use the key

colormap/BuGn-5.

This will initialize and select the associated colormap. It will also initialize the associated cycle list (but will not select it). In order to initialize and select the cycle list of name BuGn-5, you have to use the key

cycle list/BuGn-5.

This will initialize and select the associated cycle list. It will also initialize (but not select) the associated colormap.

Note that cycle lists shipped with colorbrewer merely consist of colors. However, a good cycle list typically also comes with markers and perhaps line style variations. In order to combine a pure color-based cycle list with markers, you should make use of the features cycle multi list, cycle multiindex list, and cycle multiindex* list, for example using

\pgfplotsset{ % initialize Set1-5: cycle list/Set1-5, % combine it with 'mark list*': cycle multiindex* list={ mark list*\nextlist Set1-5\nextlist }, }

Please refer to the reference manual for cycle multiindex* list for details.

5.2.2Sequential Schemes

Sequential schemes are useful for ordered data progressing low to high.

.
(-tikz- diagram) (-tikz- diagram) (-tikz- diagram)
(-tikz- diagram) (-tikz- diagram) (-tikz- diagram)
(-tikz- diagram) (-tikz- diagram) (-tikz- diagram)
(-tikz- diagram) (-tikz- diagram) (-tikz- diagram)
(-tikz- diagram) (-tikz- diagram) (-tikz- diagram)
(-tikz- diagram) (-tikz- diagram) (-tikz- diagram)
5.2.3Diverging Schemes

Diverging schemes highlight changes from some mean value.

.
(-tikz- diagram) (-tikz- diagram) (-tikz- diagram)
(-tikz- diagram) (-tikz- diagram) (-tikz- diagram)
(-tikz- diagram) (-tikz- diagram) (-tikz- diagram)

Note that you can adopt point meta min and point meta max such that the colormap’s mean value fits the data (for example by forcing point meta min=-2 and point meta max=+2).

5.2.4Qualitative Schemes

Qualitative schemes are useful if colors have no special order, but should be distinguishable.

.
(-tikz- diagram) (-tikz- diagram) (-tikz- diagram)
(-tikz- diagram) (-tikz- diagram) (-tikz- diagram)
(-tikz- diagram) (-tikz- diagram)
5.2.5Interaction with the ColorBrewer website

To find a scheme, e.g. the above chosen GnBu-7 on http://colorbrewer2.org/

  • first select the “Nature of your data” type; in this case “sequential”,

  • then select the “Number of data classes”, which is 7,

  • and last select the corresponding scheme in the “Pick a color scheme” section. (This is a bit tricky, because you can only see the name at the top of the lower right corner, where all the colors are listed. When you have selected the right one you should read there “7-class GnBu”. But perhaps it helps when you know that “Gn” stands for green and “Bu” for blue, so you are searching for a scheme going from green to blue, which in this case is the third color scheme in the first row of “Multi-hue”.)

  • The color names, e.g. GnBu-H, cannot be extracted from the page directly though, because you cannot simply count to the number and replace it with the corresponding letter. This intentionally was avoided, because then one would define the same color multiple times with different names, e.g. GnBu-H 3 times.

  • If you should need let’s say the 5th color of the scheme GnBu-7 you don’t have to trial and error or have a look at the manual. You can simply extract this color from the corresponding color map via the index of colormap feature, e.g.

    \tikz \fill[index of colormap={4 of GnBu-7}] (0,0) rectangle (1em,2ex);

    which results in (-tikz- diagram). Note that the index is \(4\) instead of \(5\) because the index starts with \(0\). Note furthermore that you have to invoke \pgfplotsset{colormap/GnBu-7} before using this key.

5.2.6External Examples

If you want to see some examples, where Brewer has used her schemes, have a look at https://www.census.gov/population/www/cen2000/atlas/index.html.

  • \usetikzlibrary{colorbrewer} % and plain

  • \usetikzlibrary[colorbrewer] % Cont

  • A library which contains just the color definitions like GnBu-B. Please refer to Section 5.2.1 for a list of available colors.