summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/tzplot/tzplot-doc-E-v2.1.tex
blob: 7ae97f306b53e591df7df3483d6029e71be410d6 (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
%!TEX root = tzplot-doc.tex
%\begin{document}

%%%%%===== PART: NOT YET!!! ==============
%%%%%%%%==================================
%%%%%\part{Miscellaneous Macros and Examples}
%%%%%%%%==================================
%%%%%\label{p:miscandexamples}
%%%%%
%%==================================

%%==================================
\chapter{Miscellany}
\label{c:misc}

%%------------------------------------------------------------
\section{Middle arrows}
\label{s:midarrows}

Four styles for middle arrow tips are predefined: |-->--|, |--o--|, |--x--| and |--/--|.

\subsection{Controllable middle arrow tips: \texttt{-->--} and \protect\cmd{\settzmidarrow}}

The middle arrow tip style \ixxw{-->--} prints a middle arrow tip of |stealth| by default.
It accepts one argument that changes the position (|0.5| by default) of a \iisw{middle arrow tip}, like |-->--=.75|.


\begin{tzcode}{.3}
\begin{tikzpicture}
% middle arrow tip: -->--
\tzhelplines(4,3)
\tzline[-->--](0,3)(4,3)
\tzline[-->--=.75,blue,thick](0,2.5)(4,2.5)
\tzto[-->--,->,out=45](0,0)(4,1)
\end{tikzpicture}
\end{tzcode}


\paragraph{How to control middle arrow tips}
The default options for middle arrow tips are |-|, |thin|, |solid|, and |shorten >=0|, and |bend right=0|. The defaults can be changed by |\settzmidarrow|.

The macro \icmd{\settzmidarrow} controls the position, style, and other options of middle arrow tips. The effect is valid until the end of the |tikzpicture| environment, unless changed again.

\begin{tzdef}
% syntax:
\settzmidarrow<position>{<arrow tip style>}[<opt>]
% all arguments are optional
% defaults:
  <0.5>{stealth}[-,thin,solid,shorten <=0,shorten >=0,bend right=0]
\end{tzdef}


\begin{tzcode}{.3}
% \settzmidarrow
\begin{tikzpicture}
\tzhelplines(4,3)
\settzmidarrow<.25>{Stealth[reversed]}[red,scale=2] %
\tzline[-->--](0,3)(4,3)
\tzline[-->--=.75,blue,thick](0,2.5)(4,2.5)
\tzto[-->--,->,out=45](0,0)(4,1)
\end{tikzpicture}
\end{tzcode}


\begin{tzcode}{.3}
% various arrow tip styles: arrows.meta
\begin{tikzpicture}
\tzhelplines(4,3)
\settzmidarrow{Circle[open]}[blue,scale=2]
\tzline[-->--](0,3)(4,3)
\tikzset{>=to}                             %%
\settzmidarrow{>>>}[blue,scale=2]
\tzline[-->--](0,2.5)(4,2.5)
\settzmidarrow<.25>{Rays}[blue,scale=2]
\tzline[-->--=.75,blue,thick](0,2)(4,2)
\tzto[-->--,->,red,out=45](0,0)(4,1)
\end{tikzpicture}
\end{tzcode}

You can use various styles of arrow tips. (See \Tikz\ manual on |arrows.meta| library, for more details.)



\subsection{Fixed middle arrow tip styles: \texttt{--o--}, \texttt{--x--}, \texttt{--/--}}

Three styles for middle arrow tips are predefined: \xem{circle} |--o--| , \xem{cross} |--x--| , and \xem{diagonal} |--/--| middle arrow tips.
These middle arrow tip styles are fixed and cannot be changed.
|\settzmidarrow| can only be used with |[<opt>]| to control these middle arrow tips.
The other options |<position>| and |{<arrow tip style>}| options are ignored for these styles.

\paragraph{Circle middle arrow tips:}

The circle middle arrow tip style \ixxw{--o--} takes one argument to change the position (|0.5| by default).

The circle is drawn like this:

\begin{verbatim}
    \draw [<opt>] (0,0) circle (1.2pt) ;
\end{verbatim}

|\settzmidarrow| controls the circle arrow tip with |<opt>|.

\begin{tzcode}{.3}
\begin{tikzpicture}
% circle middle arrow tip: --o--
\tzhelplines(4,3)
\tzline[--o--](0,3)(4,3)
\tzline[--o--=.75,blue,thick](0,2.5)(4,2.5)
\tzto[--o--,->,out=45](0,0)(4,1)
\end{tikzpicture}
\end{tzcode}

\begin{tzcode}{.3}
\begin{tikzpicture}
% \settzmidarrow: difference
\tzhelplines(4,3)
\settzmidarrow<.25>{Circle[open,fill=green]}[scale=2] %
\tzline[--o--,thick](0,3)(4,3)
\tzline[-->--=.5,blue,thick](0,2.5)(4,2.5)
\tzline[-->--,blue,thick](0,2)(4,2)
\settzmidarrow[scale=2,thick,fill=green]
\tzto[--o--=.25,->,out=45](0,0)(4,1)
\end{tikzpicture}
\end{tzcode}


\paragraph{Cross middle arrow tips:}

The cross middle arrow tip style \ixxw{--x--} takes one argument to change the position (|0.5| by default).

The cross mark is drawn like this:

\begin{verbatim}
    \draw [<opt>] (2pt,2pt)  to (-2pt,-2pt) ;
    \draw [<opt>] (-2pt,2pt) to (2pt,-2pt) ;
\end{verbatim}

|\settzmidarrow| controls the cross arrow tip with |<opt>|.

\begin{tzcode}{.3}
\begin{tikzpicture}
% cross middle arrow tip: --x--
\tzhelplines(4,3)
\tzline[--x--](0,3)(4,3)
\tzline[--x--=.75,blue,thick](0,2.5)(4,2.5)
\tzto[--x--,->,out=45](0,0)(4,1)
\end{tikzpicture}
\end{tzcode}

\begin{tzcode}{.3}
\begin{tikzpicture}
% \settzmidarrow: scale, tzextend
\tzhelplines(4,3)
\settzmidarrow<.25>{Rays[red]}[scale=2] %
\tzline[--x--,thick](0,3)(4,3)
\tzline[-->--=.5,blue,thick](0,2.5)(4,2.5)
\tzline[-->--,blue,thick](0,2)(4,2)
\settzmidarrow[thick,blue,tzextend={8pt}{8pt}]
\tzto[--x--=.25,->,out=45](0,0)(4,1)
\end{tikzpicture}
\end{tzcode}


\paragraph{Diagonal middle arrow tips}

The diagonal middle arrow tip style \ixxw{--/--} takes one argument to change the position (|0.5| by default).

The diagonal line is drawn like this:

\begin{verbatim}
    \draw [<opt>] (2pt,2pt)  to (-2pt,-2pt) ;
\end{verbatim}

|\settzmidarrow| controls the diagonal arrow tip line with |[<opt>]|.

\begin{tzcode}{.3}
\begin{tikzpicture}
% diagonal middle arrow tip: --/--
\tzhelplines(4,3)
\tzline[--/--](0,3)(4,3)
\tzline[--/--=.75,blue,thick](0,2.5)(4,2.5)
\tzto[--/--,->,out=45](0,0)(4,1)
\end{tikzpicture}
\end{tzcode}

\begin{tzcode}{.3}
\begin{tikzpicture}
% \settzmidarrow: rotate, tzextend
\tzhelplines(4,3)
\tzline[--/--,thick](0,3)(4,3)
\tzline[--/--=.25,blue,thick](0,2.5)(4,2.5)
\settzmidarrow[rotate=90,red,tzextend={3pt}{3pt}]
\tzline[--/--,blue,thick](0,2)(4,2)
\tzto[--/--=.75,->,out=45](0,0)(4,1)
\end{tikzpicture}
\end{tzcode}

\begin{tzcode}{.3}
\begin{tikzpicture}
% \settzmidarrow: bend left
\tzhelplines(4,3)
\settzmidarrow[scale=2,rotate=45,bend left=60]
\tzline[--/--,thick](0,3)(4,3)
\tzline[--/--=.25,blue,thick](0,2.5)(4,2.5)
\settzmidarrow[rotate=90,red,tzextend={3pt}{3pt}]
\tzline[--/--,blue,thick](0,2)(4,2)
\tzto[--/--=.75,->,out=45](0,0)(4,1)
\end{tikzpicture}
\end{tzcode}



%%------------------------------------------------------------
\section{\protect\cmd{\tzbrace(')}}
\label{s:tzbrace}

\icmd{\tzbrace} takes two coordinates as mandatory arguments to draw a \xem{calligraphic brace} connecting them.

\begin{tzdef}
% syntax: minimum
\tzbrace(<coor>)(<coor>)
% syntax: medium
\tzbrace(<coor>)(<coor>){<text>}[<node opt>]
% syntax: full
\tzbrace[<draw opt>]{<raise>}[<decoration opt>]<shift coor>
        (<coor>)(<coor>){<text>}[<node opt>]
% defaults
  []{5pt}[amplitude=5pt]<>(<m>)(<m>){}[]
\end{tzdef}

The |raise| value of a brace is |5pt| by default and the value can be changed by the first curly brace optional argument |{<raise>}|. 

The |amplitude| of a brace is |5pt| by default. You can control the amplitude by writing the option |amplitude=<dim>| in the second bracket option |[<decoration opt>]|.

\begin{tztikz}
\tzbrace[thick](0,0)(3,1) % works like:
  \draw [thick,decorate,decoration={calligraphic brace, amplitude=5pt, raise=5pt}]
        (0,0) to (3,1);
\end{tztikz}

The \iisw{swap version} \icmd{\tzbrace'} swaps the coordinates.
So it prints a mirror image of |\tzbrace|.
For example, |\tzbrace'(0,0)(3,1)| is equivalent to |\tzbrace(3,1)(0,0)|.

\begin{tzcode}{.3}
% \tzbrace(')
\begin{tikzpicture}[sloped]
\tzhelplines(4,2)
\tzline(0,0)(3,1)
\tzbrace(0,0)(3,1){AAA}[above=10pt,blue]
\tzbrace'[red](0,0)(3,1){BBB}[below=10pt]
\end{tikzpicture}
\end{tzcode}

You can change the style of the decorating brace by the second bracket optional argument |[<decoration opt>]|.

The color of the calligraphic brace can be changed by the option |pen colour| in the list of |[<draw option>]|.

\begin{tzcode}{.3}
% \tzbrace('): decoration options
\begin{tikzpicture}[sloped]
\tzhelplines(4,3)
\tzline(0,0)(3,1)
\tzbrace [very thick,pen colour=blue]
         [amplitude=10pt]
         (0,0)(3,1){AAA}[a=15pt]
\tzbrace'[red,very thick]{10pt}
         [brace,amplitude=10pt]
         (0,0)(3,1){BBB}[b=20pt]
\end{tikzpicture}
\end{tzcode}

You can also move a brace by specifying the option |<shift coor>| immediately before the the first mandatory coordinate.
The empty shift option |<>| is not allowed.

\begin{tzcode}{.3}
% \tzbrace('): shift
\begin{tikzpicture}[sloped]
\tzhelplines(4,3)
\tzline(0,0)(3,1)
\tzbrace [very thick,pen colour=blue][amplitude=10pt]
         <.5,.5>(0,0)(3,1){AAA}[a=15pt]
\tzbrace'[red,very thick]{10pt}[brace,amplitude=10pt]
         (0,0)(3,1){BBB}[b=20pt]
\end{tikzpicture}
\end{tzcode}




%%------------------------------------------------------------
\section{\protect\cmd{\tzsnake(+)}: Snake lines (Experimental)}
\label{s:tzsnake}

\icmd{\tzsnake} connects two points with a snaked line, with many default values, using \Tikz's |to| operation.

\begin{tztikz}
\tzsnake(0,1)(3,2) % works like
  \draw [ decorate , decoration={ %% many defaults
                                  snake,
                                  segment length=5pt, % controlled by \tzsnake
                                  amplitude=2.5pt,
                                  pre length=5pt,
                                  post length=5pt
                                }
        ]  (0,1) to (3,2) ;
\end{tztikz}

\begin{tzcode}{.3}
\begin{tikzpicture}
\tzhelplines(4,3)
\tzsnake(0,1)(3,2)
\tzsnake[->,blue,bend right](1,0)(4,3)
\end{tikzpicture}
\end{tzcode}

\begin{tzdef}
% syntax: minimum
\tzsnake(<coor>)(<coor>)
% syntax: full
\tzsnake[<opt>]{<segment length>}[<decoration opt>]<shift coor>
        (<coor>){<text>}[<node opt>]
        (<coor>){<text>}[<node opt>]<code.append>
% defaults
  []{5pt}[many defaults above]<>(<m>){}[](<m>){}[]<>
\end{tzdef}

The key |segment length| is controlled by the first curly brace option and you should write down all the other keys in the second bracket option |[<decoration opt>]| to change the values. Not specifying the option |{<segment length>}|, when the first bracket option is empty, you need empty brackets |[]|, like |\tzsnake[][<decoration opt>]...|.

\begin{tzcode}{.3}
% \tzsnake: {segment length} option
\begin{tikzpicture}
\tzhelplines(4,3)
\tzsnake[blue]{3pt}[coil](0,1){spring}[a,sloped](3,2)
\tzsnake[->,bend right]{3pt}
        [coil,amplitude=5pt,post length=20pt]
        (1,0){coil line}[b,sloped](4,3){Up!}[draw,r]
\end{tikzpicture}
\end{tzcode}

The plus version \icmd{\tzsnake+} uses the second mandatory coordinate as a relative coordinate to the first. Everything else is the same as in |\tzsnake|.


\begin{tzcode}{.3}
% \tzsnake(+): shift
\begin{tikzpicture}
\tzhelplines(4,3)
\tzsnake[->][post length=20pt](0,0)(3,0)
\tzsnake[->,red][post length=20pt]<1,1>(0,0)(3,0) %%
\tzsnake+[->,bend left,blue]{10pt}[post length=10pt]
  (0,1){snake line}[a,sloped](4,2){what?}[r]
\end{tikzpicture}
\end{tzcode}


%%%%%%%% (under construction)
%%%%%
%%%%%
%%%%%%%------------------------------------------------------------
%%%%%\section{\protect\cmd{\tzspy} (Experimental)}
%%%%%\label{s:tzspy}
%%%%%
%%%%%
%%%%%\begin{tzdef}
%%%%%% syntax: minimum
%%%%%\tzspy(<coor>)(<coor>)
%%%%%% syntax: full
%%%%%\tzbrace[<opt>]{<size>}[<maginificaltion>]
%%%%%        (<on-coor>)(<in-coor>)[<node opt>]<code.append>
%%%%%% defaults
%%%%%  [circle]{2cm}{5}(<m>)(<m>)[]<>
%%%%%\end{tzdef}
%%%%%
%%%%%To use |\tzspy| you need to tell \Tikz\ that a picture will be magnified, by specifying some special keys in the |tikzpicture| environment option, such as |spy using outlines|,  |spy using overlays|, etc., as follows:
%%%%%\begin{verbatim}
%%%%%    \begin{tikzpicture}[spy using outlines]
%%%%%      <tzplot code>
%%%%%      <tikz code>
%%%%%    \tzspy...
%%%%%    \end{tikzpicture}
%%%%%\end{verbatim}
%%%%%
%%%%%\begin{tzcode}[text above listing]
%%%%%\begin{tikzpicture}[scale=.1,font=\scriptsize,spy using outlines]
%%%%%\settzdotsize{1.2pt}
%%%%%\tzaxes(-15,0)(60,60){$Q$}{$P$}
%%%%%
%%%%%\def\Dem{50-\x}
%%%%%\def\Sup{.5*\x+5}
%%%%%\def\Supa{.5*\x+6.5}
%%%%%
%%%%%\tzfn{\Dem}[0:50]{$D$}
%%%%%\tzfn{\Sup}[-10:50]{$S$}[r]
%%%%%\tzfn{\Supa}[-10:50]{$S'$}
%%%%%
%%%%%\tzXpoint*{Dem}{Sup}(eqm)
%%%%%\tzXpoint*{Dem}{Supa}(eqma)
%%%%%\tzvXpointat*{Sup}{29}(eqmb)
%%%%%
%%%%%\tzproj[densely dotted](eqm){\rlap{300}}{200}
%%%%%\tzproj[densely dotted](eqma){\llap{290}}{\raisebox{1em}{210}}
%%%%%\tzprojy[densely dotted](eqmb){\raisebox{-2em}{195}}
%%%%%
%%%%%\tzticks{-10/-100,50/500}{5/50,50/500}
%%%%%
%%%%%\tzpath*[blue](eqm)(eqma)(eqmb);
%%%%%
%%%%%\tzspy($(eqma)!.5!(eqmb)$)(100,30)
%%%%%
%%%%%%\spy [blue,draw,circle,size=5cm, magnification = 5,connect spies]
%%%%%%on ($(eqma)!.5!(eqmb)$) in node at (100,30);
%%%%%\end{tikzpicture}
%%%%%\end{tzcode}
%%%%%
%%%%%
%%%%%\begin{tzcode}[text above listing]
%%%%%\begin{tikzpicture}[scale=.1,font=\scriptsize,spy using overlays]
%%%%%\settzdotsize{1.2pt}
%%%%%\tzaxes(-15,0)(60,60){$Q$}{$P$}
%%%%%
%%%%%\def\Dem{50-\x}
%%%%%\def\Sup{.5*\x+5}
%%%%%\def\Supa{.5*\x+6.5}
%%%%%
%%%%%\tzfn{\Dem}[0:50]{$D$}
%%%%%\tzfn{\Sup}[-10:50]{$S$}[r]
%%%%%\tzfn{\Supa}[-10:50]{$S'$}
%%%%%
%%%%%\tzXpoint*{Dem}{Sup}(eqm)
%%%%%\tzXpoint*{Dem}{Supa}(eqma)
%%%%%\tzvXpointat*{Sup}{29}(eqmb)
%%%%%
%%%%%\tzproj[densely dotted](eqm){\rlap{300}}{200}
%%%%%\tzproj[densely dotted](eqma){\llap{290}}{\raisebox{1em}{210}}
%%%%%\tzprojy[densely dotted](eqmb){\raisebox{-2em}{195}}
%%%%%
%%%%%\tzticks{-10/-100,50/500}{5/50,50/500}
%%%%%
%%%%%\tzpath*[blue](eqm)(eqma)(eqmb);
%%%%%
%%%%%\tzspy[connect spies]{5cm}[6]($(eqma)!.5!(eqmb)$)(100,30)[draw,fill=red,thick]
%%%%%\end{tikzpicture}
%%%%%\end{tzcode}
%%%%%



%%%%%%%% (under construction)
%%%%%\section{\protect\cmd{\tzplotfile}: plotting data}
%%%%%\label{s:tzplotfile}
%%%%%
%%%%%\icmd{\tzplotfile} plots data.
%%%%%
%%%%%\begin{tcblisting}{listing only}
%%%%%% syntax
%%%%%\tzplotfile[<opt>]{<file name>}[<plot opt>]
%%%%%\end{tcblisting}
%%%%%
%%%%%
%%%%%\begin{tcblisting}{listing above text}
%%%%%\begin{tikzpicture}
%%%%%\tzplotfile{sine.data}
%%%%%\end{tikzpicture}
%%%%%\end{tcblisting}
%%%%%
%%%%%\begin{tcblisting}{listing above text}
%%%%%\begin{tikzpicture}
%%%%%\tzplotfile[blue]{sine.data}[mark=x]
%%%%%\end{tikzpicture}
%%%%%\end{tcblisting}