Debian Codegraph @

texmf-dist/doc/latex/tkz-base/TKZdoc-base-axes.tex

raw
1 \section{Macros for the axes}
2
3 \tkzHandBomb\ Careful, these macros have been modified. It's now easier to use the styles of \TIKZ. \tkzcname{tkzDrawX} allows to draw an axis, \tkzcname{tkzLabelX} places graduations and finally in simple cases \tkzcname{tkzAxeX} traces and graduations. The options of \TIKZ\ are accessible.
4 Fractions can be used for graduations.
5 %<--------------------------------------------------------------------->
6 % tkzDrawX
7 %<--------------------------------------------------------------------->
8 \subsection{\tkzcname{tkzDrawX}}
9 \begin{NewMacroBox}{tkzDrawX}{\oarg{local options}}%
10 This macro allows you to draw the abscissa axis with default ticks.
11 The options are those of \TIKZ\ plus the following ones:
12
13 \medskip
14 \begin{tabular}{lll}%
15 \toprule
16 options & default & definition \\
17 \midrule
18 \TOline{color} {black} {Axis and ticks}
19 \TOline{noticks} {false} {no ticks on axis}
20 \TOline{right space}{0.5 cm} {axis extended right}
21 \TOline{left space} {0 cm} {extension of the axis to the left}
22 \TOline{label} {$x$} {label name}
23 \TOline{trig} {0} {if <>0 graduations are multiples of $pi$/trig" "trig is an integer"}
24 \TOline{tickwd} {0.8pt} {tick thickness}
25 \TOline{tickup} {1pt} {tick over axis}
26 \TOline{tickdn} {1pt} {tick depth over axis}
27 \bottomrule
28 \end{tabular}
29
30 \medskip
31 \begin{tikzpicture}[>=latex,scale=2]
32 \draw[line width=2 pt](0,0)--(4,0);
33 \draw[fill] (2cm-6pt,-14pt) rectangle (2cm+6pt,+14pt);
34 \draw[<->](2cm-6.5pt,18pt) -- (2cm+6.5pt,+18pt);
35 \node[above] at (2cm,20pt) {tickwd};
36 \draw[<->](2cm+10pt,1pt) -- (2cm+10pt,+14pt);
37 \node[right] at (2cm+10pt,8pt) {tickup};
38 \draw[<->](2cm+10pt,-1pt) -- (2cm+10pt,-14pt);
39 \node[right] at (2cm+10pt,-8pt) {tickdn};
40 \end{tikzpicture}
41
42 \medskip
43 This macro is used to draw the abscissa axis. The most important thing is to test all the options. Above, you have the values that define a tick. Otherwise the options of \TIKZ\ apply and in particular \tkzname{text}, \tkzname{color}, \tkzname{fill} and \tkzname{font}.
44 \end{NewMacroBox}
45
46 \subsubsection{No tick, no label}
47 \begin{tkzexample}[latex=8cm,small]
48 \begin{tikzpicture}
49 \tkzInit[xmax=5]
50 \tkzDrawX[label={},noticks]
51 \end{tikzpicture}
52 \end{tkzexample}
53
54 \subsubsection{Label placement}
55 \begin{tkzexample}[latex=8cm,small]
56 \begin{tikzpicture}
57 \tkzInit[xmax=5]
58 \tkzDrawX[label = quantity,
59 above left = 8pt]
60 \end{tikzpicture}
61 \end{tkzexample}
62
63
64 \subsubsection{Label and Axis Colour}
65 The color of the label is obtained with the option \tkzname{text}, that of the axis with the option \tkzname{color}.
66
67 The option \tkzname{right=12pt} shifts the label $x$ by 12 pt.
68
69 \begin{tkzexample}[latex=7cm,small]
70 \begin{tikzpicture}
71 \tkzInit[xmax=5]
72 \tkzDrawX[text=blue,color=red,right=12pt]
73 \end{tikzpicture}
74 \end{tkzexample}
75
76 \subsubsection{Option \tkzname{right space}}
77 It adds a little space after the last tick.
78 \begin{tkzexample}[latex=6cm,small]
79 \begin{tikzpicture}
80 \tkzInit[xmax=0.4,xstep=0.1]
81 \tkzDrawX[text=blue,color=red,right=12pt,right space=1]
82 \end{tikzpicture}
83 \end{tkzexample}
84
85 \subsubsection{Trigonometric axis with the option \tkzname{trig=n}}
86 If $number=0$ then the axis is graduated from cm to cm, otherwise the axis is graduated using multiples of $\frac{\pi}{number}$.
87
88 \begin{tkzexample}[latex=6cm,small]
89 \begin{tikzpicture}
90 \tkzInit[xmin=0,xmax=4,ymin=-1,ymax=1]
91 \tkzDrawX[trig=1]
92 \end{tikzpicture}
93 \end{tkzexample}
94
95 \subsubsection{Trigonometric axis with the option \tkzname{trig=2} }
96
97 \begin{tkzexample}[latex=6cm,small]
98 \begin{tikzpicture}
99 \tkzInit[xmin=0,xmax=4,ymin=-1,ymax=1]
100 \tkzDrawX[trig=2]
101 \end{tikzpicture}
102 \end{tkzexample}
103 %<--------------------------------------------------------------------->
104 % tkzLabelX
105 %<--------------------------------------------------------------------->
106 \subsection{\tkzcname{tkzLabelX}}
107 \begin{NewMacroBox}{tkzLabelX}{\oarg{local options}}%
108 This macro allows you to place graduations. The option \tkzname{orig} can be used again, but its behavior is reversed. By default, the original value is placed.
109 The options are those of \TIKZ, plus the following ones:
110
111 \medskip
112 \begin{tabular}{lll}
113 \toprule
114 options & default & definition \\
115 \midrule
116 \TOline{frac} {0}{if <>0 graduations are multiples num/frac "frac is an integer"}
117 \TOline{trig} {0}{if <>0 graduations are multiples $pi$/trig "trig is an integer"}
118 \TOline{font} {\BS textstyle} {scale size.}
119 \TOline{color} {black} {graduation color}
120 \TOline{step} {1} {interval between graduations}
121 \TOline{np off} {false} {numprint deactivation}
122 \TOline{orig} {true} {displays the origin graduation }
123 \bottomrule
124 \end{tabular}
125
126 {\tkzname{frac} and \tkzname{trig} are integers that can be changed to fractional or trigonometric writing. }
127 \end{NewMacroBox}
128
129 \subsubsection{Position of the graduations}
130 \begin{tkzexample}[latex=6cm,small]
131 \begin{tikzpicture}
132 \tkzInit[xmax=.5,xstep=0.1]
133 \tkzDrawX[label=$t$,text=blue,color=red]
134 \tkzLabelX[text=blue,below = 3pt]
135 \end{tikzpicture}
136 \end{tkzexample}
137
138
139 \subsubsection{Position of the graduations with \tkzname{xlabel style}}
140 \begin{tkzexample}[latex=5cm,small]
141 \begin{tikzpicture}
142 \tkzInit[xmin=1000,xmax=4000,xstep=1000]
143 \tkzDrawX
144 \tikzset{xlabel style/.append style={rotate=-30}}
145 \tkzLabelX[below right=3 pt,inner sep = 1pt]
146 \end{tikzpicture}
147 \end{tkzexample}
148
149 \subsubsection{Dates with \tkzname{np off}}
150 For dates, you have to deactivate numprint.
151 \begin{tkzexample}[latex=5cm,small]
152 \begin{tikzpicture}
153 \tkzInit[xmin=2000,xmax=2004]
154 \tkzDrawX
155 \tikzset{xlabel style/.append style={rotate=-30}}
156 \tkzLabelX[np off,below right=3 pt,inner sep =1pt]
157 \end{tikzpicture}
158 \end{tkzexample}
159
160 \subsubsection{\tkzname{frac}}
161 \begin{tkzexample}[latex=6cm,small]
162 \begin{tikzpicture}
163 \tkzInit[xmax=1.75,xstep=0.33333]
164 \tkzDrawX[label=$t$,text=blue,color=red]
165 \tkzLabelX[frac=3,text=blue,below = 6pt]
166 \end{tikzpicture}
167 \end{tkzexample}
168
169 \subsubsection{\tkzname{trig}}
170 \begin{tkzexample}[latex=6cm,small]
171 \begin{tikzpicture}
172 \tkzInit[xmin=0,xmax=5,ymin=-1,ymax=1]
173 \tkzDrawX[trig=2]
174 \tkzLabelX[trig=2,text=blue,below = 8pt]
175 \end{tikzpicture}
176 \end{tkzexample}
177
178 \subsubsection{Graduations size}
179 Two possibilities. It is possible to define the default style used for the math mode:
180
181 \begin{tkzltxexample}[small]
182 \let\tkzmathstyle\textstyle
183 \end{tkzltxexample}
184
185 \begin{tkzexample}[latex=6cm,small]
186 \begin{tikzpicture}
187 \tkzInit[xmin=0,xmax=5,ymin=-1,ymax=1]
188 \tkzDrawX[trig=2]
189 \tkzLabelX[trig=2,text=blue,below = 8pt]
190 \end{tikzpicture}
191 \end{tkzexample}
192
193 \begin{tkzexample}[latex=6cm,small]
194 \begin{tikzpicture}
195 \tkzInit[xmin=0,xmax=5,ymin=-1,ymax=1]
196 \let\tkzmathstyle\textstyle
197 \tkzDrawX[trig=2]
198 \tkzLabelX[trig=2,text=blue,
199 below = 8pt]
200 \end{tikzpicture}
201 \end{tkzexample}
202
203 \begin{tkzexample}[latex=6cm,small]
204 \begin{tikzpicture}
205 \tkzInit[xmin=0,xmax=5,ymin=-1,ymax=1]
206 \tkzDrawX[trig=2]
207 \tkzLabelX[trig=2,text=blue,
208 below = 8pt,node font=\small]
209 \end{tikzpicture}
210 \end{tkzexample}
211
212 \begin{tkzexample}[latex=6cm,small]
213 \begin{tikzpicture}
214 \tkzInit[xmin=0,xmax=5,ymin=-1,ymax=1]
215 \tkzDrawX[trig=2]
216 \tkzLabelX[trig=2,text=blue,
217 below = 8pt,node font=\scriptsize]
218 \end{tikzpicture}
219 \end{tkzexample}
220
221 \subsubsection{Colour of the graduations}
222 The key here is to use the color, text, and text options correctly.
223 \begin{tkzexample}[latex=7cm,small]
224 \begin{tikzpicture}
225 \tkzInit[xmin = -2,xmax = 3,
226 ymin = -2,ymax = 2]
227 \tkzDrawX[color = red,
228 label = $\displaystyle\frac{1}{t}$,
229 below = 6pt]
230 \tkzLabelX[text=blue]
231 \end{tikzpicture}
232 \end{tkzexample}
233
234 \subsubsection{Axis drawings before the graduation}
235 In some cases, it is preferable to place \tkzcname{tkzDrawXY} after \tkzcname{tkzLabelX} and \tkzcname{tkzLabelY}.
236
237 This prevents display problems.
238
239
240 \begin{tkzexample}[latex=7cm,small]
241 \begin{tikzpicture}
242 \tkzInit[xmin = -1,xmax = 4,
243 ymin = -1,ymax = 1]
244 \tkzDrawXY \tkzLabelX \tkzLabelY
245 \end{tikzpicture}
246 \end{tkzexample}
247
248 \subsubsection{Graduations (except originally) prior to tracings }
249
250 \begin{tkzexample}[latex=7cm,small]
251 \begin{tikzpicture}
252 \tkzInit[xmin = -1,xmax = 4,
253 ymin = -1,ymax = 1]
254 \tkzLabelX[orig=false]
255 \tkzLabelY[orig=false]
256 \tkzDrawXY
257 \end{tikzpicture}
258 \end{tkzexample}
259
260 \subsubsection{Only positive graduations before drawings }
261
262 \begin{tkzexample}[latex=7cm,small]
263 \begin{tikzpicture}
264 \tkzInit[xmin=2,ymin=2,xmax=4,ymax=4]
265 \tkzLabelX \tkzLabelY
266 \tkzDrawXY
267 \end{tikzpicture}
268 \end{tkzexample}
269
270 \subsubsection{No graduations at the origin }
271
272 \begin{tkzexample}[latex=7cm,small]
273 \begin{tikzpicture}
274 \tkzInit[xmin=2,ymin=2,xmax=4,ymax=4]
275 \tkzLabelX[orig] \tkzLabelY[orig]
276 \tkzDrawXY
277 \end{tikzpicture}
278 \end{tkzexample}
279 %<--------------------------------------------------------------------->
280 % tkzAxeX
281 %<--------------------------------------------------------------------->
282 \subsection{\tkzcname{tkzAxeX}}
283 \begin{NewMacroBox}{tkzAxeX}{\oarg{local options}}%
284 This macro allows you to draw the abscissa axis with default ticks as well as the graduations. It combines the two macros \tkzcname{tkzDrawX} and \tkzcname{tkzLabelX}. It should only be used in simple cases.
285
286 \medskip
287 \begin{tabular}{lll}%
288 \toprule
289 options & default & definition \\
290 \midrule
291 \TOline{label} {$x$}{label name}
292 \TOline{trig} {0}{if <>0, graduations are multiples of $pi$/trig}
293 \TOline{frac} {0}{if <>0, graduations are multiples of 1/frac}
294 \TOline{swap} {false}{allows you to run \tkzcname{tkzLabelX} before \tkzcname{tkzDrawX}}
295 \bottomrule
296 \end{tabular}
297
298 The option \tkzname{text} defines the color of the graduations.
299 \end{NewMacroBox}
300
301 \subsubsection{Example with \tkzcname{tkzAxeX}}
302 \begin{tkzexample}[latex=7cm,small]
303 \begin{tikzpicture}
304 \tkzInit[xmax=0.5,xstep=0.1,ymax=1]
305 \tkzGrid
306 \tkzAxeX[text=blue]
307 \end{tikzpicture}
308 \end{tkzexample}
309
310 \subsubsection{Use of \tkzname{pi} and \tkzcname{tkzAxeX}}
311 \begin{tkzexample}[latex=5cm,small]
312 \begin{tikzpicture}
313 \tkzInit[xmax=4,ymax=3.5]
314 \let\tkzmathstyle\displaystyle
315 \tkzLabelX[orig = false, frac = 4,below = 10pt]
316 \tkzDrawX[label = $t$]
317 \tkzAxeY[trig=2]
318 \end{tikzpicture}
319 \end{tkzexample}
320
321
322 \subsubsection{Option \tkzname{frac} and \tkzname{trig}}
323 In this example, we position the $t$ label as well as the graduations. \tkzcname{below=10pt} is used to place the graduations underneath.
324 \begin{tkzexample}[latex=5cm,small]
325 \begin{tikzpicture}
326 \tkzInit[xmax=9,xstep=3,ymax=3.5]
327 \tkzLabelX[below=10pt,orig=false,frac=3]
328 \tkzDrawX[label = $t$]
329 \tkzAxeY[trig=2]
330 \end{tikzpicture}
331 \end{tkzexample}
332
333 %<--------------------------------------------------------------------->
334 % tkzDrawY
335 %<--------------------------------------------------------------------->
336 \subsection{\tkzcname{tkzDrawY}}
337 \begin{NewMacroBox}{tkzDrawY}{\oarg{local options}}%
338 This macro allows you to draw the ordinate axis with default ticks.
339 The options are those of \TIKZ\ plus the following ones:
340
341 \medskip
342 \begin{tabular}{lll}%
343 \toprule
344 options & default & definition \\
345 \midrule
346 \TOline{color} {black} {color of axis and ticks}
347 \TOline{noticks} {false} {no ticks on the axis}
348 \TOline{up space} {0.5 cm} {top axis extension}
349 \TOline{down space} {0 cm}{axis extension down}
350 \TOline{label} {$x$}{label name}
351 \TOline{trig} {0}{if <>0, graduations are multiples of $pi$/trig "trig is an integer" }
352 \TOline{tickwd} {0.8pt}{tick's thickness}
353 \TOline{ticklt} {1pt}{height of the tick above the axis}
354 \TOline{tickrt} {1pt}{above-axis tick depth}
355 \end{tabular}
356 \end{NewMacroBox}
357
358 \subsection{\tkzcname{tkzLabelY}}
359 \begin{NewMacroBox}{tkzLabelY}{\oarg{local options}}%
360 This macro allows you to draw the abscissa axis with default ticks.
361 The options are those of \TIKZ\ plus the following ones:
362
363 \medskip
364 \begin{tabular}{lll}%
365 \toprule
366 options & default & definition \\
367 \midrule
368 \TOline{color} {black} {graduation color}
369 \TOline{frac} {0}{if <>0, graduations are multiples of $1$/frac "frac is an integer"}
370 \TOline{font} {\BS textstyle} {graduation size.}
371 \TOline{step} {1} {interval between graduations}
372 \bottomrule
373 \end{tabular}
374
375 {\tkzname{frac} is a integer that can be changed to fractional or trigonometric writing.}
376 \end{NewMacroBox}
377
378 %<--------------------------------------------------------------------->
379 % tkzAxeY
380 %<--------------------------------------------------------------------->
381 \subsection{\tkzcname{tkzAxeY}}
382 \begin{NewMacroBox}{tkzAxeY}{\oarg{local options}}%
383 This macro combines the two macros:
384 \tkzcname{tkzDrawY} \tkzcname{tkzLabelY}
385 See \tkzcname{tkzAxeX} for options.
386 \end{NewMacroBox}
387 %<--------------------------------------------------------------------->
388 % tkzAxeXY
389 %<--------------------------------------------------------------------->
390 \subsection{\tkzcname{tkzAxeXY}}
391 \begin{NewMacroBox}{tkzAxeXY}{\oarg{local options}}%
392 This macro combines the four macros:
393 \tkzcname{tkzDrawX}\tkzcname{tkzDrawY} \tkzcname{tkzLabelX}\tkzcname{tkzLabelY}
394
395 It is necessary to use common options as in the example below, but this means that the same options are applied to both macros. Thus it is not possible to change \tkzname{label}.
396 \end{NewMacroBox}
397
398 \subsubsection{Colour of axes, graduations}
399
400 \begin{tkzexample}[latex=6cm]
401 \begin{tikzpicture}
402 \tkzInit[xmin=-1,xmax=4,ymin=-1,ymax=3]
403 \tkzAxeXY[label={},text=blue]
404 \end{tikzpicture}
405 \end{tkzexample}
406
407 \subsubsection{Option \tkzname{label=\{\}}}
408
409 \begin{tkzexample}[latex=6cm,small]
410 \begin{tikzpicture}
411 \tkzInit[xmin=-1,xmax=4,ymin=-1,ymax=2]
412 \tkzAxeXY[label={},text=blue,trig=2]
413 \end{tikzpicture}
414 \end{tkzexample}
415
416 \subsubsection{Option \tkzname{swap}}
417 \begin{tkzexample}[latex=6cm,small]
418 \begin{tikzpicture}
419 \tkzInit[xmin=-2,xmax=2,ymin=-2,ymax=2]
420 \tkzAxeXY[label={},swap]
421 \end{tikzpicture}
422 \end{tkzexample}
423 %<--------------------------------------------------------------------->
424 % tkzDrawXY
425 %<--------------------------------------------------------------------->
426 \subsection{\tkzcname{tkzDrawXY}}
427 \begin{NewMacroBox}{tkzDrawXY}{\oarg{local options}}%
428 This macro combines the two macros: \tkzcname{tkzDrawX}\tkzcname{tkzDrawY}.
429 It is necessary to use common options as in the example below.
430 \end{NewMacroBox}
431
432 \subsubsection{Common colour and empty labels}
433 \begin{tkzexample}[latex=6cm,small]
434 \begin{tikzpicture}
435 \tkzInit[xmin=-1,xmax=4,ymin=-1,ymax=1]
436 \tkzDrawXY[label={},color=red]
437 \end{tikzpicture}
438 \end{tkzexample}
439
440 \subsubsection{Two trigonometric axes}
441 \begin{tkzexample}[latex=6cm,small]
442 \begin{tikzpicture}
443 \tkzInit[xmin=-1,xmax=4,ymin=-1,ymax=1]
444 \tkzDrawXY[label={},color=red,trig=4]
445 \end{tikzpicture}
446 \end{tkzexample}
447 %<--------------------------------------------------------------------->
448 % tkzLabelXY
449 %<--------------------------------------------------------------------->
450 \subsection{\tkzcname{tkzLabelXY}}
451 \begin{NewMacroBox}{tkzLabelXY}{\oarg{local options}}%
452 This macro combines the two macros:
453
454 \tkzcname{tkzLabelX}\tkzcname{tkzLabelY}
455
456 It is necessary to use common options as in the example below.
457 \end{NewMacroBox}
458
459 \subsubsection{}
460 \begin{tkzexample}[latex=6cm,small]
461 \begin{tikzpicture}
462 \tkzInit[xmin=-1,xmax=4,ymin=-1,ymax=1]
463 \tkzDrawXY[label={},color=red]
464 \tkzLabelXY[text=blue]
465 \end{tikzpicture}
466 \end{tkzexample}
467
468 %<--------------------------------------------------------------------->
469 % tkzSetUpAxis
470 %<--------------------------------------------------------------------->
471 \subsection{Changing values by axis default}
472
473 \begin{NewMacroBox}{tkzSetUpAxis}{\oarg{local options}}%
474 \begin{tabular}{lll}%
475 options & default & definition \\
476 \midrule
477 \TOline{line width}{|0.4pt|}{line width defines the width of the line}
478 \TOline{tickwd}{|0.8pt|}{tick thickness }
479 \TOline{ticka}{|1pt|}{right side or above the tick }
480 \TOline{tickb}{|1pt|}{left side or below the tick }
481 \TOline{font}{|\tkzcname{textstyle}|}{graduation size.}
482 \end{tabular}
483 \end{NewMacroBox}
484
485 \subsubsection{Changing the default axes}
486 \begin{tkzexample}[latex=5cm,small]
487 \begin{tikzpicture}[scale=1]
488 \tkzInit[ymax=2,xmax=4]
489 \tkzSetUpAxis[line width=1pt,tickwd=1pt,ticka=3pt, tickb=0pt]
490 \tkzAxeXY
491 \end{tikzpicture}
492 \end{tkzexample}
493
494 You have to run \tkzcname{tkzSetUpAxis} again to retrieve the default values.
495
496 \medskip
497 \begin{tkzltxexample}[small]
498 \tkzSetUpAxis[line width=1pt,tickwd=1pt,ticka=2pt,tickb=2pt]
499 \end{tkzltxexample}
500
501 \tkzSetUpAxis[line width=1pt,tickwd=1pt,ticka=2pt,tickb=2pt]
502
503 \endinput