summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pictex/errorbars.tex
blob: 0f9271bfeb23b8f252b34ea29c1fdefe63fedfaa (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
%
%	TeX macros to plot error bars with the PicTeX macros.
%
%	These macros are largely derived from the examples in the back
%	of the PiCTeX manual.
%
%	To plot with a mark at each data point, simply say
%
%	\plotWith mark M at x1 y1 x2 y2 .... xN yN /
%
%	where "M" is a mark character {e.g. $\bullet$}
%
%	To include error bars in the plot, say:
%
%	\plotWithErrorBars mark M at
%		x1 y1 e1
%		x2 y2 e2 .... xN yN eN
%	/
%
%	The line-breaking isn't needed. Marks are placed on the graph
%	at (xi, yi) for each data point. Vertical error bars are drawn
%	from (xi, yi + ei) to (xi, yi - ei).
%
%	The cross-bar at the top and bottom of the error bars is normally
%	5 pts, but can be changed by setting the \crossbarlength dimen.
%
%
%	Dirk Grunwald Apr 20 1988
%
%
\newdimen\dyposition
\newdimen\crossbarlength
\crossbarlength=5pt
\newdimen\lastPlotX
\newdimen\lastPlotY
\newdimen\tmpPlotX
\newdimen\tmpPlotY
%
%
\def\plotErrorBar#1 #2 #3 #4{%
    \message{ Plot #4 at #1 #2 }%
    \put {#4} at {#1} {#2}
    \dyposition=\Ydistance{#3}
    \put{%
      \vbox{%
	\hsize=\crossbarlength%
	\hrule height \linethickness%
	\vskip -.5\linethickness%
	\centerline{\vrule width \linethickness height 2\dyposition}%
	\nointerlineskip%
	\vskip -.5\linethickness%
	\hrule height \linethickness}%
    } at {#1} {#2} }
%
\def\plotWithErrorBars mark #1 at #2 #3 #4 {%
    \def\errorBarMark{#1}%
    %
    %    plot first point
    %
    \plotErrorBar {#2} {#3} {#4} {\errorBarMark}
    \lastPlotX=\Xdistance{#2}%
    \lastPlotY=\Ydistance{#3}%
    \futurelet\nextcharacter\plotErrorBarLoop}
%
\def\plotErrorBarLoop{%
    \if/\nextcharacter%
	\def\plotErrorBarAction{\plotErrorBarFinish}%
    \else%
	\def\plotErrorBarAction{\plotErrorBarContinued}%
    \fi%
    \plotErrorBarAction}
%
\def\plotErrorBarFinish/ {}
%
\def\plotErrorBarContinued#1 #2 #3 {%
    \plotErrorBar {#1} {#2} {#3} {\errorBarMark}%
    \tmpPlotX = \Xdistance{#1}%
    \tmpPlotY = \Ydistance{#2}%
    \setdimensionmode%
    \plot {\lastPlotX} {\lastPlotY} {\tmpPlotX} {\tmpPlotY} /
    \setcoordinatemode%
    \lastPlotX = \tmpPlotX%
    \lastPlotY = \tmpPlotY%
    \futurelet\nextcharacter\plotErrorBarLoop}
%    
\def\plotWith mark #1 at #2 #3 {%
    \def\plotWithMark{#1}%
    %
    %    plot first point
    %
    \message{Plot {\plotWithMark} at #2 #3}%
    \put {\plotWithMark} at {#2} {#3}
    \lastPlotX=\Xdistance{#2}%
    \lastPlotY=\Ydistance{#3}%
    \futurelet\nextcharacter\plotWithLoop}
%
\def\plotWithLoop{%
    \if/\nextcharacter%
	\def\plotWithAction{\plotWithFinish}%
    \else%
	\def\plotWithAction{\plotWithContinued}%
    \fi%
    \plotWithAction}
%
\def\plotWithFinish/ {}
%
\def\plotWithContinued#1 #2 {%
    \message{ Plot {\plotWithMark} at #1 #2}%
    \put {\plotWithMark} at {#1} {#2}
    \tmpPlotX = \Xdistance{#1}%
    \tmpPlotY = \Ydistance{#2}%
    \setdimensionmode%
    \plot {\lastPlotX} {\lastPlotY} {\tmpPlotX} {\tmpPlotY} /
    \setcoordinatemode%
    \lastPlotX = \tmpPlotX%
    \lastPlotY = \tmpPlotY%
    \futurelet\nextcharacter\plotWithLoop}