1\section{Extensibility\label{extend}}
2Two kinds of extensibilities will be described in this section.
3On one hand, regarding the \sdd\ design, the extensibility of the \RR\ graphics system will be discussed;
4it provides the tools and features enabling the programmer to write complex
5high level plot functions in a very general manner.
6On the other hand we describe the extensibility of \sdd\ itself.
7
8
9\subsection{Extensibility of \RR\ graphics\label{exR}}
10\RR\ provides a huge collection of low level graphic functions like those
11for adding elements to an existing plot or for computations related to
12plotting.
13%
14These functions are used to build very general high level functions, at
15least for the two dimensional case, and without them, the ``\RR\ code
16only'' design of \sdd\ would be impossible.
17
18A selection of these low level functions begins with the functions to obtain $x$, $y$ (and~$z$) coordinates for plotting,
19namely {\tt xy.coords} and {\tt xyz.coords} (for the 3D case, cf.\ Section \ref{xyzcoords}).
20Further on, the functions {\tt plot.new} and {\tt plot.window} can be used to set up the plotting region appropriately,
21{\tt pretty} to calculate pretty axis tick marks,
22{\tt segments} to draw line segments between pairs of points,
23and functions like {\tt title}, {\tt axis}, {\tt points}, {\tt lines}, {\tt text} etc.~are self-explanatory.
24
25A huge collection of graphical parameters for \RR\ is documented in the
26help pages for {\tt par} and {\tt plot.default} (cf.\ R core \citeyear{r-ref}).
27Almost all low level graphic functions make use of the argument `\code{...}'
28which allows specifying most of these parameters in a very general manner.
29If this argument, `\code{...}', is also used in a high level function,
30arguments which are not \textsl{explicitly} introduced in the arguments list,
31can be passed through to lower level graphic functions as well;  this
32is a powerful feature of the \textsf{S} language.
33
34\enlargethispage{5mm}
35Since the \RR\ graphics system is designed for two dimensional graphics,
36it lacks of some features for the three dimensional case.
37%%
38Unfortunately, the {\tt axis} function works only for 2D graphics.
39Consequently a large amount of code was required to
40enable oblique axes for displaying the 3D scatter plot in an arbitrary
41angle.
42
43Locations in \RR\ graphics devices can be addressed with 2D coordinates,
44Thus the information on the projection has to be calculated by the 3D graphic functions internally.
45As described in Section \ref{design}, \sdd\ uses a parallel projection.
46Since the \RR\ graphics device does not know anything about the projection,
47without any appropriate additional tools it is not possible to add elements into an existing \sdd .
48
49
50\subsection{Extensibility of \sdd\label{exsdd}}
51In Sections \ref{introduction} and \ref{design} it was emphasized
52that the \sdd\ design was intended to be as general as possible.
53Some attempts to obtain this generality are described in Section \ref{design} and its subsections.
54%%
55Because of the missing projection information, the ability of adding
56elements to an already existing \sdd\ would be restricted, if only the
57already defined (and for the 2D case general) \RR\ functions could be used
58(cf.\ Section \ref{exR}).
59
60For this reason, \sdd\ (invisibly) returns a list of \textsl{function
61  closures} (cf.\ Section~\ref{structure}).
62A \textsl{function closure} is a function together with an
63\textsl{environment},  and an \textsl{environment} is a collection of
64symbols and associated values (i.e. \RR\ variables). Thus these properties
65  of \RR's scoping rules, called \textsl{Lexical Scoping}
66  (\cite{gentleman}), are extensively used in \sdd.
67%
68Notice that \textsl{Lexical Scoping} is a feature of \RR, not defined as
69such in the \textsf{S} language.
70
71In other words, the values returned by \sdd\ are functions together with
72the environment in which they (and the scatter plot) were created.
73The benefit of returning function closures is, that the function somehow
74``knows'' the values of variables (in the environment) that were assigned
75to those variables at the time when the function was created.  All in all,
76we made those functions know details about the axis scaling and the
77projection information that are required to add elements to an existing
78plot appropriately.
79
80The following functions are returned by \sdd , for details see the Appendix:\\ \vspace{-11mm}
81\begin{description} \setlength\itemsep{0.5ex plus0.2ex minus0.3ex}
82\item[{\tt xyz.convert}:] A function which converts 3D coordinates to the 2D parallel projection of the existing \sdd .
83                        It is useful to add arbitrary elements into the plot.
84\item[{\tt points3d}:]  A function which draws points or lines into the existing plot.
85\item[{\tt plane3d}:]   A function which draws a plane into the existing plot:\\
86    \verb+plane3d(Intercept, x.coef=NULL, y.coef=NULL, lty="dashed", ...)+.
87    Instead of an intercept, a vector containing three elements or an \textsf{(g)lm} object can be specified.
88\item[{\tt box3d}:]     This function draws a box (or ``refreshes'' an existing one) around the plot.
89\end{description}
90{\tt xyz.convert} is the most important function, because it does the parallel projection
91by converting the given 3D coordinates into the 2D coordinates needed for the \RR\ graphics devices.
92Examples how to use the mentioned function closures are given in Section \ref{examples}.
93
94