summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/pgfplots/test/pgfplotstest/pgfplotstest.ticks.tex
blob: e687e1055e21266b4ab83c9fd04744fa333292bd (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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
\testfile{pgfplotstest.ticks.tex}
\testsection{Minor ticks}
\begin{tikzpicture}
\begin{axis}[minor tick num=3]
\smallplotstest
\end{axis}
\end{tikzpicture}
%\endinput
\begin{tikzpicture}
\begin{axis}[minor tick num=1]
\smallplotstest
\end{axis}
\end{tikzpicture}

\begin{tikzpicture}
\begin{axis}[minor tick num=5]
\smallplotstest
\end{axis}
\end{tikzpicture}

\begin{tikzpicture}
%\tracingmacros=2\tracingcommands=2
\begin{axis}[minor tick num=5,xtick={0.5,1,2,2.5,3}]
\smallplotstest
\end{axis}
%\tracingmacros=0\tracingcommands=0
\end{tikzpicture}

\testsection{Tick placement}
\begin{tikzpicture}
\begin{axis}[
	xtick={-1.5,-1,...,1.5},
	ytick={-0.5,0,...,1.5},
	]
\smallplotstest
\end{axis}
\end{tikzpicture}

\begin{tikzpicture}
\begin{axis}[
	xmin=0,xmax=1,
	xtick={-1.5,-1.25,...,1.5}]
\smallplotstest
\end{axis}
\end{tikzpicture}

\testsubsection{xtick=data}
\begin{tikzpicture}
\begin{axis}[xtick=data,xmajorgrids]
\addplot coordinates {(0,0) (0.4,1) (1,2) (1.2,3) (4,5)};
\end{axis}
\end{tikzpicture}

\begin{tikzpicture}
\begin{axis}[xtick=data,xmajorgrids]
\addplot coordinates {(0,0) (0.4,1) (1,2) (1.2,3) (4,5)};
\addplot coordinates {(0.1,1) (0.5,2) (1.2,3)};
\end{axis}
\end{tikzpicture}

\begin{tikzpicture}
\begin{loglogaxis}[xtick=data,xmajorgrids]
\loglogtestplot
\end{loglogaxis}
\end{tikzpicture}

\testsubsubsection{ytick=data}
\begin{tikzpicture}
\begin{axis}[ytick=data,ymajorgrids]
\addplot coordinates {(0,0) (0.4,1) (1,2) (1.2,3) (4,5)};
\addplot coordinates {(0.1,1) (0.5,2) (1.2,3)};
\end{axis}
\end{tikzpicture}

\begin{tikzpicture}
\begin{loglogaxis}[ytick=data,ymajorgrids]
\loglogtestplot
\end{loglogaxis}
\end{tikzpicture}

\testsubsection{ticks on axis rectangle}
First plot: default tick style; second plot: red, third: 'help lines'

{\pgfplotsset{every axis/.append style={
	enlargelimits=false,
	xmin=-40,xmax=40,ymin=-40,ymax=40,
	xtick={-40,0,40},
	ytick={-40,0,40}
}}%
\begin{tikzpicture}
\begin{axis}[
]
\addplot coordinates {(-40,-40) (40,40)};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[
	tick style={red,line width=5pt,major tick length=20pt},
]
\addplot coordinates {(-40,-40) (40,40)};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[
	tick style={help lines},
]
\addplot coordinates {(-40,-40) (40,40)};
\end{axis}
\end{tikzpicture}
}

\testsubsection{modified labels}

{
\pgfplotsset{every axis label/.style={}}
\pgfplotsset{every axis x label/.style={
    at={(0.5,1)},
    above,
    yshift=+15pt}}
\pgfplotsset{every axis y label/.style={
    at={(1,0.5)},
    xshift=+35pt,
    rotate=90}}

\begin{tikzpicture}
\begin{axis}[
	xlabel=$x$ axis,
	ylabel=$y$ axis,
	xmin=0,xmax=1,
	tickpos=right,
	xtick={-1.5,-1.25,...,1.5}]
\smallplotstest
\end{axis}
\end{tikzpicture}
}

\begin{tikzpicture}
\begin{axis}[
	xlabel=$x$ axis,
	ylabel=$y$ axis,
	xmin=0,xmax=1,
	tickpos=both,
	xtick={-1.5,-1.25,...,1.5}]
\smallplotstest
\end{axis}
\end{tikzpicture}

\testsection{Tick label assigment tests}
\testsubsection{Using xticklabel and xtick}
\begin{tikzpicture}
\begin{axis}[
	xtick={-1.5,-1,...,1.5},
	xticklabel={%
		\ifcase\ticknum	$-1\frac12$%
		\or				$-1$%
		\or				$-\frac12$%
		\or				$0$%
		\or				$\frac12$%
		\or				$1$%
		\or				$1\frac12$%
		\else			$\tick$%
		\fi
	}
]
\smallplotstest
\end{axis}
\end{tikzpicture}

\testsubsection{Using xticklabels}%
\begin{tikzpicture}
\begin{axis}[
	xtick={-1.5,-1,...,1.5},
	xticklabels={%
		$-1\frac 12$,
		$-1$,
		$-\frac 12$,
		$0$,
		$\frac 12$,
		$1$}
]
\smallplotstest
\end{axis}
\end{tikzpicture}

\testsubsection{With xtick labels and commas by hand}
\begin{tikzpicture}
\begin{axis}[
	xtick={-1.5,-1,...,1.5},
	xticklabels={%
		{-1,5},
		-1,
		{-0,5},
		0,
		{0,5},
		1,
		{1,5}}
]
\smallplotstest
\end{axis}
\end{tikzpicture}

{
\testsubsection{Only with auto number formatting options; different for x and y}
%\tracingmacros=2\tracingcommands=2
\begin{tikzpicture}
\begin{axis}[
	xtick={-1.5,-1,...,1.5},
	x tick label style={/pgf/number format/use comma},
	y tick label style={/pgf/number format/.cd,use comma,fixed zerofill,precision=3},
]
\smallplotstest
\end{axis}
\end{tikzpicture}
}

\testsubsection{Using yticklabels in logplot}%
{
\def\tickformat#1{1e#1}%
\begin{tikzpicture}
\begin{loglogaxis}[
	ytick={1e-8,1e-7,1e-6,1e-5,1e-4,1e-3,1e-2,1e-1,1e0,1e1},
	yticklabels={%
		\tickformat{-8},
		\tickformat{-7},
		\tickformat{-6},
		\tickformat{-5},
		\tickformat{-4},
		\tickformat{-3},
		\tickformat{-2},
		\tickformat{-1},
		\tickformat{-0}}
]
\loglogtestplot
\end{loglogaxis}
\end{tikzpicture}
}

\testsection{Tick/Tick-Label placement log plots}
\testsubsection{ytickten}
\begin{tikzpicture}
\begin{loglogaxis}[
	%xmin=0.99e2,xmax=1e4,
	ytickten={-5,-4,-3.6,-3,-2,-1,0},
	yticklabel={
		\ifnum\ticknum=2	
			$\rightarrow$
		\else
			\axisdefaultticklabellog
		\fi
	}
]
\loglogtestplot
\end{loglogaxis}
\end{tikzpicture}

\testsubsection{ytick}
\begin{tikzpicture}
\begin{loglogaxis}[
	ytick={1e-5,1e-4,0.000251188643,1e-3,1e-2,1e-1,1e0},
]
\loglogtestplot
\end{loglogaxis}
\end{tikzpicture}

\testsubsection{extra y ticks}
\begin{tikzpicture}
\begin{loglogaxis}[
	extra y ticks={0.000251188643,5e-2},
]
\loglogtestplot
\end{loglogaxis}
\end{tikzpicture}

\testsubsection{extra y ticks and formatted label}
\begin{tikzpicture}
\begin{loglogaxis}[
	extra y ticks={0.000251188643,5e-2},
]
\loglogtestplot
\end{loglogaxis}
\end{tikzpicture}

\testsubsection{extra x and y ticks, linear plot}
\begin{tikzpicture}
\begin{axis}[
	xmin=0,xmax=3,ymin=0,ymax=15,
	extra y ticks={2.71828},
	extra y tick labels={$e$},
	extra x ticks={2.2},
	extra x tick style={grid=major,/pgfplots/tick label style={rotate=90,anchor=east}},
	extra x tick labels={Cut}
]
	\addplot (\x,{exp(\x)});
	\addlegendentry{$e^x$}
\end{axis}
\end{tikzpicture}