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.13Number Formatting Options

pgfplots typesets tick labels rounded to given precision and in configurable number formats. The command to do so is \pgfmathprintnumber; it uses the current set of number formatting options. In addition, pgfplots might prepare tick numbers before they are handed over to \pgfmathprintnumber.

The options related to number printing as such are described in all detail in the manual for PgfplotsTable, which comes with pgfplots. This section contains the reference for everything which is specific to an axis, and only a brief survey over the number formatting options as such.

4.13.1Frequently Used Number Printing Settings

This section provides a brief survey about the most frequently used aspects of number formatting in pgfplots.

  • 1. pgfplots computes common tick scaling factors like \(\cdot 10^2\) and produces only integers as tick labels.

    In order to get numbers like \(0.001\) as tick labels instead of \(1\) with a separate label \(\cdot 10^{-3}\), you can use scaled ticks=false in your axis. See the description of scaled ticks for details.

  • 2. In order to customize the way numbers are rounded and/or displayed, use something like xticklabel style={/pgf/number format/.cd,fixed,precision=5}.

    Here is a short list of possibilities:

    123.46

    \pgfmathprintnumber{123.456789}

    12,345.68

    \pgfmathprintnumber{12345.6789}

    12,345.6789

    \pgfmathprintnumber [fixed,precision=5]{12345.6789}

    12,345.67890

    \pgfmathprintnumber [fixed,fixed zerofill,precision=5]{12345.6789}

    12.345,67890

    \pgfmathprintnumber [fixed,fixed zerofill,precision=5,use comma] {12345.6789}

    1.23 · 104

    \pgfmathprintnumber [sci]{12345.6789}

    1.23457 · 104

    \pgfmathprintnumber [sci,sci zerofill,precision=5]{12345.6789}

    1.23 × 101

    \pgfmathprintnumber [sci,sci generic= {mantissa sep=\times,exponent={10^{#1}}}] {12.345}

    ; 1 1 3 2

    \pgfmathprintnumber[frac]{0.333333333333333}; \pgfmathprintnumber[frac]{0.5}

    +2

    \pgfmathprintnumber[print sign]{2}

    (image)

    \pgfmathprintnumber [1000 sep={\,},fixed,precision=6]{1000000.123456}

    (image)

    \pgfmathprintnumber[ 1000 sep={\,},fixed,precision=6, 1000 sep in fractionals] {1000000.123456}

    Each of these keys requires the prefix ‘/pgf/number format/’ when used inside of a pgfplots style (try /pgf/number format/.cd,(math image)number formatting keys(math image) to use the same prefix for many (math image)number formatting keys(math image)).

    The number formatting uses \pgfmathprintnumber, a pgf command to typeset numbers. A full reference of all supported options is shipped with pgfplots: it is documented in the reference manual for PgfplotsTable, Section ‘Number Formatting Options’. The same reference can be found in the documentation for pgf.

    Note that the number printer knows nothing about pgfplots. In particular, it is not responsible for logs and their representation.

  • 3. For a logarithmic axis, one may want to modify the number formatting style for the exponent only. In this case, redefine the style log plot exponent style (its documentation contains a couple of examples).

  • 4. In order to get fixed point tick labels on a logarithmic axis, you can use log ticks with fixed point (see below).

4.13.2PGFPlots-specific Number Formatting

This section contains fine-tuning options to change number formatting aspects – but only things which are specific to pgfplots like peculiarities of tick labels on logarithmic axes. Consider browsing Section 4.13.1 first to see if you need this section.

  • \pgfmathprintnumber{(math image)x(math image)}

  • Generates pretty-printed output for the (real) number (math image)x(math image). The input number (math image)x(math image) is parsed using \pgfmathfloatparsenumber which allows arbitrary precision.

    Numbers are typeset in math mode using the current set of number printing options, see below. Optional arguments can also be provided using \pgfmathprintnumber[(math image)options(math image)]{(math image)x(math image)}.

    Please refer to the manual of PgfplotsTable (shipped with this package) for details about options related to number-printing.

  • /pgfplots/log number format code/.code={(math image)...(math image)}

  • Provides code to generate log plot tick labels. Argument ‘#1’ is the (natural) logarithm of the tick position. The default implementation invokes log base 10 number format code after it changed the log basis to \(10\). It also checks the other log plot options.

    This key will have a different meaning when the log basis has been chosen explicitly, see the log basis x key.

  • /pgfplots/log base 10 number format code/.code={(math image)...(math image)}

  • Allows to change the overall appearance of base 10 log plot tick labels. The default implementation invokes log number format basis={10}{#1}.

    Use log plot exponent style if you only want to change number formatting options for the exponent.