tikz.dev / PGFplots Manual

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

The Reference

\(\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}}}\)

4.18Style Options

4.18.1All Supported Styles

pgfplots provides many styles to customize its appearance and behavior. They can be defined and changed in any place where keys are allowed. Furthermore, own styles are defined easily.

  • Key handler (math image)key(math image)/.style={(math image)key-value-list(math image)}

  • Defines or redefines a style (math image)key(math image). A style is a normal key which will set all options in (math image)key-value-list(math image) when it is set.

    Use \pgfplotsset{(math image)key(math image)/.style={(math image)key-value-list(math image)}} to (re)define a style (math image)key(math image) in the namespace /pgfplots.

  • Key handler (math image)key(math image)/.append style={(math image)key-value-list(math image)}

  • Appends (math image)key-value-list(math image) to an already existing style (math image)key(math image). This is the preferred method to change the predefined styles: if you only append, you maintain compatibility with future versions.

    Use \pgfplotsset{(math image)key(math image)/.append style={(math image)key-value-list(math image)}} to append (math image)key-value-list(math image) to the style (math image)key(math image). This will assume the prefix /pgfplots.

Styles installed for linear/logarithmic axis
  • /pgfplots/every axis(style, initially empty)

  • Installed at the beginning of every axis. TikZ options inside of it will be used for anything inside of the axis rectangle and any axis descriptions.

  • /pgfplots/every semilogx axis(style, initially empty)

  • Installed at the beginning of every plot with logarithmic \(x\)-axis and linear \(y\)-axis, but after ‘every axis’.

  • /pgfplots/every semilogy axis(style, initially empty)

  • Likewise, but with interchanged roles for \(x\) and \(y\).

  • /pgfplots/every loglog axis(style, initially empty)

  • Installed at the beginning of every log–log plot.

  • /pgfplots/every linear axis(style, initially empty)

  • Installed at the beginning of every plot with normal axis scaling.

Styles installed for single plots
  • /pgfplots/every axis plot(style, initially empty)

  • Installed for each plot. This style may contain options like samples, gnuplot parameters, error bars and it may contain options which affect the final drawing commands.

  • /pgfplots/every axis plot no #(style, initially empty)

  • Used for every #th plot where \(\#=0,1,2,3,4,\dotsc \).

    This style is installed before the argument list of \addplot(math image)options(math image), i.e. (math image)options(math image) are preferred. Note that this also means that any items in a cycle list have higher priority.

  • /pgfplots/every forget plot(style, initially empty)

  • Used for every plot which has forget plot activated.

Styles for axis descriptions
  • /pgfplots/every axis label(style, initially empty)

  • Used for all axis label (like xlabel and ylabel).

  • /pgfplots/every axis x label(style, no value)

  • /pgfplots/every axis y label(style, no value)

  • /pgfplots/every axis z label(style, no value)

  • Used only for \(x\), \(y\), or \(z\) labels, respectively and installed after ‘every axis label’.

    The initial settings are set by xlabel absolute and its variants (if the initial configuration compat=pre 1.3 is active) or xlabel near ticks which provides the better spacing as it incorporates the tick label sizes to compute the position.

Attention:

These styles will be overwritten by axis x line and/or axis y line. Please remember to place your modifications after the axis line variations.

  • /pgfplots/every axis title(style, no value)

  • Used for any axis title. The at=((math image)x,y(math image)) syntax will place the title using axis description cs.

    The initial setting is

    \pgfplotsset{every axis title/.style={at={(0.5,1)},above,yshift=6pt}}

    To be more precise, the yshift doesn’t use the hardcoded 6pt: it uses the value of

    • /pgfplots/every axis title shift={(math image)default shift(math image)} (initially 6pt)

    which can be reset if needed.

  • /pgfplots/every legend image post(style, no value)

  • Allows to change the appearance of the small legend images after the options of the plot style have been applied. Thus, legend formatting can be changed independently of the plot style using every legend image post.

    This key is also documented on page (page for section 4.9.5).

  • /pgfplots/every legend to name picture(style, no value)

  • A style for use with legend to image, see the documentation therein.

  • /pgfplots/every colorbar(style, no value)

  • A style to change the colorbar. See page (page for section 4.9.13) for the reference documentation of every colorbar.

Styles for axis lines
  • /pgfplots/every outer x axis line(style, initially empty)

  • /pgfplots/every outer y axis line(style, initially empty)

  • /pgfplots/every outer z axis line(style, initially empty)

  • Installed for every axis line which lies on the outer box.

    If you want arrow heads, you may also need to check the separate axis lines boolean key.

  • /pgfplots/every inner x axis line(style, initially empty)

  • /pgfplots/every inner y axis line(style, initially empty)

  • /pgfplots/every inner z axis line(style, initially empty)

  • Installed for every axis line which is drawn using the center or middle options.

  • /pgfplots/axis line style={(math image)key-value-list(math image)}

  • /pgfplots/inner axis line style={(math image)key-value-list(math image)}

  • /pgfplots/outer axis line style={(math image)key-value-list(math image)}

  • /pgfplots/x axis line style={(math image)key-value-list(math image)}

  • /pgfplots/y axis line style={(math image)key-value-list(math image)}

  • /pgfplots/z axis line style={(math image)key-value-list(math image)}

  • These options modify parts of the axis line styles. They append options to every inner x axis line and every outer x axis line and the respective \(y\)/\(z\) variants.

Please refer to Section 4.9.9 on page (??) for details about styles for axis lines.

  • /pgfplots/every 3d box foreground(style, no value)

  • Installed for the parts drawn by 3d box=complete. This affects axis lines, tick lines and grid lines drawn in the foreground. The background drawing operations have already been done when this style is evaluated.

  • /pgfplots/every colorbar sampled line(style, no value)

  • To be used in conjunction with colorbar sampled line, see the documentation therein.

Styles for ticks
  • /pgfplots/every tick(style, initially very thin,gray)

  • Installed for each of the small tick lines.

  • /pgfplots/every minor tick(style, initially empty)

  • Used for each minor tick line, installed after ‘every tick’.

  • /pgfplots/every major tick(style, initially empty)

  • Used for each major tick line, installed after ‘every tick’.

  • /pgfplots/every tick label(style, initially empty)

  • Used for each \(x\) and \(y\) tick labels.

  • /pgfplots/every x tick label(style, initially empty)

  • /pgfplots/every y tick label(style, initially empty)

  • /pgfplots/every z tick label(style, initially empty)

  • Used for each \(x\) (or \(y\) or \(z\), respectively) tick label, installed after ‘every tick label’.

  • /pgfplots/every x tick(style, initially empty)

  • /pgfplots/every y tick(style, initially empty)

  • /pgfplots/every z tick(style, initially empty)

  • Installed for tick lines on either \(x\)- or \(y\)-axis.

  • /pgfplots/every minor x tick(style, initially empty)

  • /pgfplots/every minor y tick(style, initially empty)

  • /pgfplots/every minor z tick(style, initially empty)

  • Installed for minor tick lines on either \(x\)- or \(y\)-axis.

  • /pgfplots/every major x tick(style, initially empty)

  • /pgfplots/every major y tick(style, initially empty)

  • /pgfplots/every major z tick(style, initially empty)

  • Installed for major tick lines on either \(x\)- or \(y\)-axis.

Styles for grid lines
  • /pgfplots/every axis grid(style, initially thin,black!25)

  • Used for each grid line.

  • /pgfplots/every minor grid(style, initially empty)

  • Used for each minor grid line, installed after ‘every axis grid’.

  • /pgfplots/every major grid(style, initially empty)

  • Likewise, for major grid lines.

  • /pgfplots/every axis x grid(style, initially empty)

  • /pgfplots/every axis y grid(style, initially empty)

  • /pgfplots/every axis z grid(style, initially empty)

  • Used for each grid line in either \(x\) or \(y\) direction.

  • /pgfplots/every minor x grid(style, initially empty)

  • /pgfplots/every minor y grid(style, initially empty)

  • /pgfplots/every minor z grid(style, initially empty)

  • Used for each minor grid line in either \(x\) or \(y\) direction.

  • /pgfplots/every major x grid(style, initially empty)

  • /pgfplots/every major y grid(style, initially empty)

  • /pgfplots/every major z grid(style, initially empty)

  • Used for each major grid line in either \(x\) or \(y\) direction.

Styles for error bars
  • /pgfplots/every error bar(style, initially thin)

  • Installed for every error bar.

4.18.2(Re)Defining Own Styles

Use \pgfplotsset{(math image)style name(math image)/.style={(math image)key-value-list(math image)}} to create own styles. If (math image)style name(math image) exists already, it will be replaced. Please note that it is not possible to use the TikZ command \tikzstyle{(math image)style name(math image)}=[] in this context.63

(-tikz- diagram)

% Preamble: \pgfplotsset{width=7cm,compat=1.18} \pgfplotsset{ my personal style/.style={ grid=major, font=\large, }, } \begin{tikzpicture} \begin{axis}[my personal style] \addplot coordinates {(0,0) (1,1)}; \end{axis} \end{tikzpicture}

63 This was possible in a previous version and is still supported for backwards compatibility. But in some cases, it may not work as expected.