summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tkz/tkz-base/doc/latex/TKZdoc-base-axes.tex
blob: 0090b80e76fbafd86f6cbb5ec428f815a0a8557f (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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
\section{Macros for the axes}

 \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. 
Fractions can be used for graduations.
%<--------------------------------------------------------------------->
%                  tkzDrawX
%<--------------------------------------------------------------------->
\subsection{\tkzcname{tkzDrawX}} \hypertarget{dx}{}
\begin{NewMacroBox}{tkzDrawX}{\oarg{local options}}%
This macro allows you to draw the abscissa axis with default ticks.
The options are those of \TIKZ\ plus the following ones:

\medskip
\begin{tabular}{lll}%
\toprule
options  & default & definition   \\
\midrule
\TOline{color}      {black}  {Axis and ticks}
\TOline{noticks}    {false}  {no ticks on axis}
\TOline{right space}{0,5 cm} {axis extended right}
\TOline{left space} {0 cm}   {extension of the axis to the left}
\TOline{label}      {$x$}    {label name}
\TOline{trig}       {0}      {if <>0 pi/trig is the unit}
\TOline{tickwd}     {0.8pt}  {tick thickness}
\TOline{tickup}     {1pt}    {tick over axis}
\TOline{tickdn}     {1pt}    {tick depth over axis}
\bottomrule
\end{tabular}

\medskip
\begin{tikzpicture}[>=latex,scale=2]
  \draw[line width=2 pt](0,0)--(4,0);
  \draw[fill] (2cm-6pt,-14pt) rectangle (2cm+6pt,+14pt);
  \draw[<->](2cm-6.5pt,18pt) -- (2cm+6.5pt,+18pt);
  \node[above] at (2cm,20pt) {tickwd};
  \draw[<->](2cm+10pt,1pt) -- (2cm+10pt,+14pt);
  \node[right] at (2cm+10pt,8pt) {tickup};
  \draw[<->](2cm+10pt,-1pt) -- (2cm+10pt,-14pt);
  \node[right] at (2cm+10pt,-8pt) {tickdn};
\end{tikzpicture}

\medskip
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}. 
\end{NewMacroBox}

\subsubsection{No tick, no label}
\begin{tkzexample}[latex=8cm,small]
\begin{tikzpicture}
 \tkzInit[xmax=5]
 \tkzDrawX[label={},noticks]
\end{tikzpicture}
\end{tkzexample}

\subsubsection{Label placement}
\begin{tkzexample}[latex=8cm,small]
\begin{tikzpicture}
 \tkzInit[xmax=5]
 \tkzDrawX[label      = quantity,
           above left = 8pt]
\end{tikzpicture}
\end{tkzexample}


\subsubsection{Label and Axis Colour}
The color of the label is obtained with the option \tkzname{text}, that of the axis with the option \tkzname{color}.

The option \tkzname{right=12pt} shifts the label $x$ by 12 pt.

\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}
  \tkzInit[xmax=5]
  \tkzDrawX[text=blue,color=red,right=12pt]
\end{tikzpicture}
\end{tkzexample}

\subsubsection{Option \tkzname{right space}}
It adds a little space after the last tick.
\begin{tkzexample}[latex=6cm,small]
\begin{tikzpicture}
\tkzInit[xmax=0.4,xstep=0.1]
\tkzDrawX[text=blue,color=red,right=12pt,right space=1]
\end{tikzpicture}
\end{tkzexample}

 \subsubsection{Trigonometric axis with the option \tkzname{trig=1}}\hypertarget{newm}{}
If number=0 then the axis is graduated from cm to cm, otherwise the axis is graduated using multiples of $\frac{\pi}{number}$.

\begin{tkzexample}[latex=6cm,small]
\begin{tikzpicture}
  \tkzInit[xmin=0,xmax=4,ymin=-1,ymax=1]
  \tkzDrawX[trig=1]
\end{tikzpicture}
\end{tkzexample}

\subsubsection{Trigonometric axis with the option \tkzname{trig=2} }

\begin{tkzexample}[latex=6cm,small]
\begin{tikzpicture}
  \tkzInit[xmin=0,xmax=4,ymin=-1,ymax=1]
  \tkzDrawX[trig=2]
\end{tikzpicture}
\end{tkzexample}
%<--------------------------------------------------------------------->
%                  tkzLabelX
%<--------------------------------------------------------------------->
\subsection{\tkzcname{tkzLabelX}}\hypertarget{lx}{}
\begin{NewMacroBox}{tkzLabelX}{\oarg{local options}}%
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.
The options are those of \TIKZ, plus the following ones:

\medskip
\begin{tabular}{lll}
\toprule
options  & default & definition   \\
\midrule
\TOline{frac}     {0}{if <>0  graduations = num/frac "frac is an integer"}
\TOline{trig}     {0}{if <>0  pi/trig "trig is an integer"}
\TOline{font} {\BS textstyle} {scale size.}
\TOline{color}  {black} {graduation color}
\TOline{step}  {1} {interval between graduations}
\TOline{np off}  {false} {numprint deactivation}
\TOline{orig}  {true} {displays the origin graduation }
\bottomrule
\end{tabular}

{\tkzname{frac} and \tkzname{trig} are integers that can be changed to fractional or trigonometric writing. }
\end{NewMacroBox}

\subsubsection{Position of the graduations}
\begin{tkzexample}[latex=6cm,small]
\begin{tikzpicture}
\tkzInit[xmax=.5,xstep=0.1]
\tkzDrawX[label=$t$,text=blue,color=red]
\tkzLabelX[text=blue,below = 3pt]
\end{tikzpicture}
\end{tkzexample}


\subsubsection{Position of the graduations with \tkzname{xlabel style}}
\begin{tkzexample}[latex=5cm,small]
\begin{tikzpicture}
 \tkzInit[xmin=1000,xmax=4000,xstep=1000]
 \tkzDrawX
 \tikzset{xlabel style/.append style={rotate=-30}}
 \tkzLabelX[below right=3 pt,inner sep = 1pt]
\end{tikzpicture}
\end{tkzexample}

\subsubsection{Dates with \tkzname{np off}}
For dates, you have to deactivate numprint.
\begin{tkzexample}[latex=5cm,small]
\begin{tikzpicture}
 \tkzInit[xmin=2000,xmax=2004]
 \tkzDrawX
 \tikzset{xlabel style/.append style={rotate=-30}}
 \tkzLabelX[np off,below right=3 pt,inner sep =1pt]
\end{tikzpicture}
\end{tkzexample}

\subsubsection{\tkzname{frac}}
\begin{tkzexample}[latex=6cm,small]
\begin{tikzpicture}
\tkzInit[xmax=1.75,xstep=0.33333]
\tkzDrawX[label=$t$,text=blue,color=red]
\tkzLabelX[frac=3,text=blue,below = 6pt]
\end{tikzpicture}
\end{tkzexample}

\subsubsection{\tkzname{trig}}
\begin{tkzexample}[latex=6cm,small]
\begin{tikzpicture}
  \tkzInit[xmin=0,xmax=5,ymin=-1,ymax=1]
  \tkzDrawX[trig=2]
  \tkzLabelX[trig=2,text=blue,below = 8pt]
\end{tikzpicture}
\end{tkzexample}

\subsubsection{Graduations size}
Two possibilities. It is possible to define the default style used for the math mode:

\begin{tkzltxexample}[small]
\let\tkzmathstyle\textstyle
\end{tkzltxexample}

\begin{tkzexample}[latex=6cm,small]
\begin{tikzpicture}
  \tkzInit[xmin=0,xmax=5,ymin=-1,ymax=1]
  \tkzDrawX[trig=2]
  \tkzLabelX[trig=2,text=blue,below = 8pt]
\end{tikzpicture}
\end{tkzexample}

\begin{tkzexample}[latex=6cm,small]
\begin{tikzpicture}
  \tkzInit[xmin=0,xmax=5,ymin=-1,ymax=1]
  \let\tkzmathstyle\textstyle
  \tkzDrawX[trig=2]
  \tkzLabelX[trig=2,text=blue,
            below = 8pt]
\end{tikzpicture}
\end{tkzexample}

\begin{tkzexample}[latex=6cm,small]
\begin{tikzpicture}
  \tkzInit[xmin=0,xmax=5,ymin=-1,ymax=1]
  \tkzDrawX[trig=2]
  \tkzLabelX[trig=2,text=blue,
           below = 8pt,node font=\small]
\end{tikzpicture}
\end{tkzexample}

\begin{tkzexample}[latex=6cm,small]
\begin{tikzpicture}
  \tkzInit[xmin=0,xmax=5,ymin=-1,ymax=1]
  \tkzDrawX[trig=2]
  \tkzLabelX[trig=2,text=blue,
      below = 8pt,node font=\scriptsize]
\end{tikzpicture}
\end{tkzexample}

\subsubsection{Colour of the graduations}
The key here is to use the color, text, and text options correctly. \tkzname{fill}
\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}
  \tkzInit[xmin = -2,xmax = 3,
           ymin = -2,ymax = 2]
 \tkzDrawX[color = red,
           label = $\displaystyle\frac{1}{t}$,
           below = 6pt]
 \tkzLabelX[text=blue]
\end{tikzpicture}
\end{tkzexample}

\subsubsection{Axis drawings before the graduation}
In some cases, it is preferable to place \tkzcname{tkzDrawXY} after \tkzcname{tkzLabelX} and \tkzcname{tkzLabelY}. 

This prevents display problems.


\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}
\tkzInit[xmin = -1,xmax = 4,
         ymin = -1,ymax = 1]
\tkzDrawXY \tkzLabelX  \tkzLabelY
\end{tikzpicture}
\end{tkzexample}

\subsubsection{Graduations (except originally) prior to tracings  }

\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}
   \tkzInit[xmin = -1,xmax = 4,
            ymin = -1,ymax = 1]
   \tkzLabelX[orig=false] 
   \tkzLabelY[orig=false]
   \tkzDrawXY
\end{tikzpicture}
\end{tkzexample}

\subsubsection{Only positive graduations before drawings }

\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}
  \tkzInit[xmin=2,ymin=2,xmax=4,ymax=4]
  \tkzLabelX \tkzLabelY
  \tkzDrawXY
\end{tikzpicture}
\end{tkzexample}

\subsubsection{No graduations at the origin }

\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}
  \tkzInit[xmin=2,ymin=2,xmax=4,ymax=4]
  \tkzLabelX[orig]    \tkzLabelY[orig]
  \tkzDrawXY
\end{tikzpicture}
\end{tkzexample}
%<--------------------------------------------------------------------->
%                  tkzAxeX
%<--------------------------------------------------------------------->
\subsection{\tkzcname{tkzAxeX}}\hypertarget{ax}{}
\begin{NewMacroBox}{tkzAxeX}{\oarg{local options}}%
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. 

\medskip
\begin{tabular}{lll}%
\toprule
options  & default & definition   \\
\midrule
\TOline{label} {$x$}{label name}
\TOline{trig} {0}{graduation fraction de $\pi$}
\TOline{frac} {0}{fractional, denominator graduation « frac »}
\TOline{swap} {false}{allows you to run \tkzcname{tkzLabelX} before \tkzcname{tkzDrawX}}
\bottomrule
\end{tabular}

The option \tkzname{text} defines the color of the graduations.
\end{NewMacroBox}

\subsubsection{Example with \tkzcname{tkzAxeX}}
\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}
   \tkzInit[xmax=0.5,xstep=0.1,ymax=1]
   \tkzGrid
   \tkzAxeX[text=blue]
\end{tikzpicture}
\end{tkzexample}

\subsubsection{Use of \tkzname{pi} and \tkzcname{tkzAxeX}}
\begin{tkzexample}[latex=5cm,small]
\begin{tikzpicture}
  \tkzInit[xmax=4,ymax=3.5]
  \let\tkzmathstyle\displaystyle
  \tkzLabelX[orig  = false, frac  = 4,below = 10pt]
  \tkzDrawX[label = $t$]
  \tkzAxeY[trig=2]
\end{tikzpicture}
\end{tkzexample}


\subsubsection{Option \tkzname{frac} and \tkzname{trig}}
In this example, we position the $t$ label as well as the graduations.  \tkzcname{below=10pt} is used to place the graduations underneath.
\begin{tkzexample}[latex=5cm,small]
\begin{tikzpicture}
  \tkzInit[xmax=9,xstep=3,ymax=3.5]
  \tkzLabelX[below=10pt,orig=false,frac=3]
  \tkzDrawX[label = $t$]
  \tkzAxeY[trig=2]
\end{tikzpicture}
\end{tkzexample}

%<--------------------------------------------------------------------->
%                  tkzDrawY
%<--------------------------------------------------------------------->
\subsection{\tkzcname{tkzDrawY}} \hypertarget{dy}{}
\begin{NewMacroBox}{tkzDrawY}{\oarg{local options}}%
This macro allows you to draw the ordinate axis with default ticks.
The options are those of \TIKZ\ plus the following ones:

\medskip
\begin{tabular}{lll}%
\toprule
options  & default & definition   \\
\midrule
\TOline{color}      {black} {color of axis and ticks}
\TOline{noticks}    {false} {no ticks on the axis}
\TOline{up space}   {0,5 cm} {top axis extension}
\TOline{down space} {0 cm}{axis extension down}
\TOline{label}      {$x$}{label name}
\TOline{trig}       {0}{if <>0  pi/trig is the unit}
\TOline{tickwd}     {0.8pt}{tick's thickness}
\TOline{ticklt}     {1pt}{height of the tick above the axis}
\TOline{tickrt}     {1pt}{above-axis tick depth}
\end{tabular}
\end{NewMacroBox}

\subsection{\tkzcname{tkzLabelY}} \hypertarget{ly}{}
\begin{NewMacroBox}{tkzLabelY}{\oarg{local options}}%
This macro allows you to draw the abscissa axis with default ticks.
The options are those of \TIKZ\ plus the following ones:

\medskip
\begin{tabular}{lll}%
\toprule
options  & default & definition   \\
\midrule
\TOline{color}  {black} {graduation color}
\TOline{frac} {0}{if <>0 graduations are denominator fractions=frac}
\TOline{font} {\BS textstyle} {graduation size.}
\TOline{step}  {1} {interval between graduations}
\bottomrule
\end{tabular}

{\tkzname{frac} and \tkzname{trig} are integers that can be changed to fractional or trigonometric writing. }
\end{NewMacroBox}

%<--------------------------------------------------------------------->
%                  tkzAxeY
%<--------------------------------------------------------------------->
\subsection{\tkzcname{tkzAxeY}}\hypertarget{ay}{}
\begin{NewMacroBox}{tkzAxeY}{\oarg{local options}}%
This macro combines the two macros:
\tkzcname{tkzDrawY} \tkzcname{tkzLabelY}
Voir \tkzcname{tkzAxeX} for options
\end{NewMacroBox}
%<--------------------------------------------------------------------->
%                  tkzAxeXY
%<--------------------------------------------------------------------->
\subsection{\tkzcname{tkzAxeXY}}  \hypertarget{axy}{}
\begin{NewMacroBox}{tkzAxeXY}{\oarg{local options}}%
This macro combines the four macros:
\tkzcname{tkzDrawX}\tkzcname{tkzDrawY} \tkzcname{tkzLabelX}\tkzcname{tkzLabelY}

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}.
\end{NewMacroBox}

\subsubsection{Colour of axes, graduations}

\begin{tkzexample}[latex=6cm]
\begin{tikzpicture}
  \tkzInit[xmin=-1,xmax=4,ymin=-1,ymax=3]
  \tkzAxeXY[label={},text=blue]
\end{tikzpicture}
\end{tkzexample}

\subsubsection{Option \tkzname{label=\{\}}}

\begin{tkzexample}[latex=6cm,small]
\begin{tikzpicture}
  \tkzInit[xmin=-1,xmax=4,ymin=-1,ymax=2]
  \tkzAxeXY[label={},text=blue,trig=2]
\end{tikzpicture}
\end{tkzexample}

\subsubsection{Option \tkzname{swap}}
\begin{tkzexample}[latex=6cm,small]
\begin{tikzpicture}
\tkzInit[xmin=-2,xmax=2,ymin=-2,ymax=2]
\tkzAxeXY[label={},swap]
\end{tikzpicture}
\end{tkzexample}
%<--------------------------------------------------------------------->
%                  tkzDrawXY
%<--------------------------------------------------------------------->
\subsection{\tkzcname{tkzDrawXY}}  \hypertarget{dxy}{}
\begin{NewMacroBox}{tkzDrawXY}{\oarg{local options}}%
This macro combines the two macros: \tkzcname{tkzDrawX}\tkzcname{tkzDrawY}.
It is necessary to use common options as in the example below
\end{NewMacroBox}

\subsubsection{Common colour and empty labels}
\begin{tkzexample}[latex=6cm,small]
\begin{tikzpicture}
   \tkzInit[xmin=-1,xmax=4,ymin=-1,ymax=1]
   \tkzDrawXY[label={},color=red]
\end{tikzpicture}
\end{tkzexample}

\subsubsection{Two trigonometric axes}
\begin{tkzexample}[latex=6cm,small]
\begin{tikzpicture}
  \tkzInit[xmin=-1,xmax=4,ymin=-1,ymax=1]
  \tkzDrawXY[label={},color=red,trig=4]
\end{tikzpicture}
\end{tkzexample}
%<--------------------------------------------------------------------->
%                  tkzLabelXY
%<--------------------------------------------------------------------->
\subsection{\tkzcname{tkzLabelXY}}  \hypertarget{lxy}{}
\begin{NewMacroBox}{tkzLabelXY}{\oarg{local options}}%
This macro combines the two macros:

 \tkzcname{tkzLabelX}\tkzcname{tkzLabelY}

It is necessary to use common options as in the example below.
\end{NewMacroBox}

\subsubsection{}
\begin{tkzexample}[latex=6cm,small]
\begin{tikzpicture}
  \tkzInit[xmin=-1,xmax=4,ymin=-1,ymax=1]
  \tkzDrawXY[label={},color=red]
  \tkzLabelXY[text=blue]
\end{tikzpicture}
\end{tkzexample}

%<--------------------------------------------------------------------->
%                  tkzSetUpAxis
%<--------------------------------------------------------------------->
\subsection{Changing values by axis default} \hypertarget{axis}{}

\begin{NewMacroBox}{tkzSetUpAxis}{\oarg{local options}}%
\begin{tabular}{lll}%
options  & default & definition   \\
\midrule
\TOline{line width}{|0.4pt|}{line width defines the width of the line}
\TOline{tickwd}{|0.8pt|}{tick thickness  }
\TOline{ticka}{|1pt|}{right side or above the tick  }
\TOline{tickb}{|1pt|}{left side or below the tick  }
\TOline{font}{|\tkzcname{textstyle}|}{graduation size.}
\end{tabular}
\end{NewMacroBox}

\subsubsection{Changing the default axes}
\begin{tkzexample}[latex=5cm,small]
\begin{tikzpicture}[scale=1]
 \tkzInit[ymax=2,xmax=4]
 \tkzSetUpAxis[line width=1pt,tickwd=1pt,ticka=3pt, tickb=0pt]
 \tkzAxeXY
\end{tikzpicture}
\end{tkzexample}

You have to run \tkzcname{tkzSetUpAxis } again to retrieve the default values.

\medskip
\begin{tkzltxexample}[small]
\tkzSetUpAxis[line width=1pt,tickwd=1pt,ticka=2pt,tickb=2pt]
\end{tkzltxexample}

\tkzSetUpAxis[line width=1pt,tickwd=1pt,ticka=2pt,tickb=2pt]

\endinput