summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pictex/errorbars.tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-01-12 23:46:03 +0000
committerKarl Berry <karl@freefriends.org>2006-01-12 23:46:03 +0000
commit873660d1a83ece926fe7206288dda9c36b349c1b (patch)
treea48f77125c309a355b5d0eb58d6b24446abe9d62 /Master/texmf-dist/tex/generic/pictex/errorbars.tex
parent2939242967231097459df0fc3150fabc2f639111 (diff)
generic 1
git-svn-id: svn://tug.org/texlive/trunk@613 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/pictex/errorbars.tex')
-rw-r--r--Master/texmf-dist/tex/generic/pictex/errorbars.tex117
1 files changed, 117 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/generic/pictex/errorbars.tex b/Master/texmf-dist/tex/generic/pictex/errorbars.tex
new file mode 100644
index 00000000000..0f9271bfeb2
--- /dev/null
+++ b/Master/texmf-dist/tex/generic/pictex/errorbars.tex
@@ -0,0 +1,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}