summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/pgfplots/pgfplots.reference.numberformatting.tex
blob: 3504fcbdb1866356e8316023fcdb2bc4b0d1cbc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154

\subsection{Number Formatting Options}
\label{sec:number:printing}%
\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.

These options are described in all detail in the manual for \PGFPlotstable, which comes with \PGFPlots. Please refer to that manual.

\begin{command}{\pgfmathprintnumber\marg{x}}
Generates pretty-printed output for the (real) number \meta{x}. The input number \meta{x} 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[|\meta{options}|]|\marg{x}.

Please refer to the manual of \PGFPlotstable\ (shipped with this package) for details about options related to number-printing.
\end{command}

\label{sec:identify:minor:log}%
\begin{pgfplotskey}{log identify minor tick positions=\mchoice{true,false} (initially false)}
Set this to |true| if you want to identify log--plot tick labels at positions 
\[ i \cdot 10^j \]
with $i \in \{2,3,4,5,6,7,8,9\},\, j \in \Z$. This may be valuable in conjunction with the `|extra x ticks|' and `|extra y ticks|' options.
\begin{codeexample}[]
\begin{tikzpicture}%
\begin{loglogaxis}
	[title=Standard options,
	width=6cm]
\addplot coordinates {
	(1e-2,10)
	(3e-2,100)
	(6e-2,200)
};
\end{loglogaxis}
\end{tikzpicture}%
\end{codeexample}

\begin{codeexample}[]
\pgfplotsset{every axis/.append style={%
	width=6cm,
	xmin=7e-3,xmax=7e-2,
	extra x ticks={3e-2,6e-2},
	extra x tick style={major tick length=0pt,font=\footnotesize}
}}%

\begin{tikzpicture}%
	\begin{loglogaxis}[
		xtick={1e-2},
		title=with minor tick identification,
		extra x tick style={
			log identify minor tick positions=true}]
	\addplot coordinates {
		(1e-2,10)
		(3e-2,100)
		(6e-2,200)
	};
	\end{loglogaxis}
\end{tikzpicture}%

\begin{tikzpicture}%
	\begin{loglogaxis}[
		xtick={1e-2},
		title=without minor tick identification,
		extra x tick style={
			log identify minor tick positions=false}]
	\addplot coordinates {
		(1e-2,10)
		(3e-2,100)
		(6e-2,200)
	};
	\end{loglogaxis}%
\end{tikzpicture}%
\end{codeexample}
	This key is set by the default styles for extra ticks.
\end{pgfplotskey}

\begin{pgfplotscodekey}{log number format code}
Provides \TeX-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.
\end{pgfplotscodekey}


\begin{pgfplotscodekey}{log base 10 number format code}
Allows to change the overall appearance of base 10 log plot tick labels. The default is
\begin{codeexample}[code only]
\pgfplotsset{
	log base 10 number format code/.code={$10^{\pgfmathprintnumber{#1}}$}
}
\end{codeexample}
where the `|log plot exponent style|' allows to change number formatting options.
\end{pgfplotscodekey}

\begin{pgfplotscodekey}{log number format basis}
	This part of the representation routines for log ticks in \emph{arbitrary} basis (see the |log basis x| key). It is used instead of the key above if the log basis has been changed. The first supplied argument is the log basis, the second the exponent. The initial configuration is
\begin{codeexample}[code only]
\pgfplotsset{
	/pgfplots/log number format basis/.code 2 args={$#1^{\pgfmathprintnumber{#2}}$}
}
\end{codeexample}
\end{pgfplotscodekey}

\begin{pgfplotskey}{log plot exponent style=\marg{key-value-list}}
Allows to configure the number format of log plot exponents. This style is installed just before `|log base 10 number format code|' will be invoked. Please note that this style will be installed within the default code for `|log number format code|'.
\begin{codeexample}[]
\pgfplotsset{
	samples=15,
	width=7cm,
	xlabel=$x$,
	ylabel=$f(x)$,
	extra y ticks={45},
	legend style={at={(0.03,0.97)},
		anchor=north west}}

\begin{tikzpicture}
\begin{semilogyaxis}[
	log plot exponent style/.style={
		/pgf/number format/fixed zerofill,
		/pgf/number format/precision=1},
	domain=-5:10]

	\addplot {exp(x)};
	\addplot {exp(2*x)};

	\legend{$e^x$,$e^{2x}$}
\end{semilogyaxis}
\end{tikzpicture}
\end{codeexample}

\begin{codeexample}[]
\pgfplotsset{
	samples=15,
	width=7cm,
	xlabel=$x$,
	ylabel=$f(x)$,
	extra y ticks={45},
	legend style={at={(0.03,0.97)},
		anchor=north west}}

\begin{tikzpicture}
\begin{semilogyaxis}[
	log plot exponent style/.style={
		/pgf/number format/fixed,
		/pgf/number format/use comma,
		/pgf/number format/precision=2},
	domain=-5:10]

	\addplot {exp(x)};
	\addplot {exp(2*x)};

	\legend{$e^x$,$e^{2x}$}
\end{semilogyaxis}
\end{tikzpicture}
\end{codeexample}
\end{pgfplotskey}