Graphics Device for the X11 Window System

DESCRIPTION:
Creates a graphics window on an X11 server. This function is deprecated; use motif instead.

USAGE:
X11(options="", ...)


OPTIONAL ARGUMENTS:
options:
vector of character strings specifying X11 command line options, such as -xrm (for X Toolkit style resource specifications) and -display. See your X11 documentation, the examples below, and the chapter Customizing Your S-PLUS Session in the S-PLUS User's Manual for more information.
...:
other options are passed through to the printer drivers used by printgraph. Refer to ps.options for the list of valid commands for the PostScript driver. Each PostScript option should be prefixed with ps. in order to be passed through and recognized as a PostScript driver option. Note that the LaserJet driver has not yet been updated to use this scheme.

SIDE EFFECTS:
a graphics window is created on the screen specified by the -display option or the DISPLAY environment variable. If your resource specifications are incompatible with the X server (e.g., the server does not have the specified font, or color, or space for the specified number of halftone patterns), X11 will report it is "Bailing Out!" and you must try starting it again with a different set of resources before you can do any plotting.

DETAILS:
The X11 driver is included primarily for compatibility with versions of S-PLUS older than 3.0. Two replacements, openlook and motif, have since been added. Since these drivers provide features not present in X11, such as interactive color scheme editing and defaults saving, we recommend that you use either of these graphics devices instead.

Static plots will be automatically rescaled when the size of the graphics window is changed through the window manager, but it is advised that the window not be resized while running brush or spin.

Do not destroy the S-PLUS graphics window through a window manager supplied menu; if you no longer want the window, use the dev.off function.

If you get the error:

X11 Toolkit Error : Can't Open display

while trying to start the X11 graphics device, there are two likely causes of the problem: Your DISPLAY environment variable may be set incorrectly (or not set at all), and/or the machine that you are running S-PLUS on does not have access to your X11 server.

First, make sure your DISPLAY variable is set correctly. Exit S-PLUS (with the q() function) and type the following (for the UNIX C-Shell):

setenv DISPLAY machinename:displaynumber.screennumber

where machinename is the name of the machine running the X11 server (the computer you are sitting in front of), and displaynumber and screennumber designate the display and screen of that machine. In most cases, both of these numbers will be "0". For example, if you are sitting in front of a workstation named "fay", which has one X11 display and one screen, you will want to type:

setenv DISPLAY fay:0.0

(If you do not know the name of the machine that is running the X11 server, and you are running S-PLUS on the same machine, you may substitute "unix" for the name of the machine. Also, note that the display may be specified as an option to the X11 function. The S-PLUS command:

X11("-display fay:0.0")

will attempt to show its graphics window on "fay's" X11 server.)

If you are running S-PLUS and the X11 server on different machines, the steps above may not be enough to allow you to access your display. The machine running S-PLUS must have access to the X11 server. To accomplish this, type the following at a UNIX shell prompt on the machine running the X11 server:

xhost + machinename

where machinename is the name of the machine running S-PLUS. For example, if you are running S-PLUS on a computer named "donna" and are sitting in front of a computer named "fay", you will want to type

xhost + donna

at a shell prompt on "fay", to which you should get the response:

donna being added to access control list

(Note that the use of xhost supercedes "MIT-MAGIC-COOKIE" security. If you wish to abide by that system, consult your X11 documentation or your system administrator for information on how to allow remote hosts access to X11 servers using xauth.)

If, after following the steps above, you are still unable to gain display access, consult your system administrator or X11 documentation.

In the example below, we show how to make an S-PLUS graphics window when remotely logged in on a machine named "cyclops" from a machine named "betty" running X11. There will be two graphics fonts, cex=1 will give you font0 (10 point helvetica, Roman style). You will have eight colors: the background (color 0) is white, and then 7 foreground colors blending smoothly from red to green to blue. Lines and filled polygons will use these 7 foreground colors. The image command will interpolate between these 7 colors with 7 halftone patterns, giving images with 49 colors. This color selection is reasonable for a color display with only four color planes. If you have lots of pure colors available (8 planes would give you 256 pure colors), then you could set "nHalftones" to 0 and "halftoneImage" to No and set "colors" to many smoothly changing values (use larger integers between the colors). Note that hexidecimal representations of colors can be used (see the X11 Window System documentation for details). The last entry ("Font") makes the command buttons and menus use the font name "fixed".

If the X11 resource database is properly set up, there is seldom a need to pass options to the X11 command (except for color maps). The Customizing Your S-PLUS Session chapter of The S-PLUS User's Manual describes how to set up the X11 resource database.


REFERENCES:
Quercia, V. and O'Reilly, T. (1988) X Window System User's Guide. O'Reilly & Associates, Inc.

The Window System Details and Customizing Your S-PLUS Session chapters of The S-PLUS User's Manual.

The Setting the Defaults for Your Window System chapter of the S-PLUS Installation and Maintenance Manual.


SEE ALSO:
openlook , motif , X11SETUP , Devices , printgraph , dev.cur , Device.Default , brush , spin , image , the xcm datasets.

EXAMPLES:
{betty}% xhost + cyclops        # Run this command on betty, the X server machine.
                        # This allows cyclops to put a window on betty.
{betty}% rlogin cyclops
{cyclops}% Splus
> X11.betty <- c("-display betty:0.0",
                 "-xrm 'splus*defaultFont:0'",
                 "-xrm 'splus*fonts:*helvetica-*-R-*-10-*
                                    *helvetica-*-R-*-14-*'",
                 "-xrm 'splus*colors: white red 2 green 2 blue'",
                 "-xrm 'splus*nHalftones:7'",
                 "-xrm 'splus*halftonePolygon:No'",
                 "-xrm 'splus*halftoneImage:Yes'",
                 "-xrm 'splus*Font:fixed'")
> X11(X11.betty)
# do some plotting

# another call to X11 > X11(c("-d betty:0", xcm.heatB))