windows {grDevices} | R Documentation |
A graphics device is opened. For windows
, win.graph
,
x11
and X11
this is a graphics window on the current
Windows display: the multiple names are for compatibility with other
systems. win.metafile
prints to a file and win.print
to
the Windows print system.
windows(width = 7, height = 7, pointsize = 12, record = getOption("graphics.record"), rescale = c("R", "fit", "fixed"), xpinch, ypinch, bg = "transparent", canvas = "white", gamma = getOption("gamma"), xpos = NA, ypos = NA, buffered = getOption("windowsBuffered"), restoreConsole = FALSE) win.graph(width = 7, height = 7, pointsize = 12, restoreConsole = FALSE) x11(width = 7, height = 7, pointsize = 12, restoreConsole = FALSE) X11(width = 7, height = 7, pointsize = 12, restoreConsole = FALSE) win.metafile(filename = "", width = 7, height = 7, pointsize = 12, restoreConsole = TRUE) win.print(width = 7, height = 7, pointsize = 12, printer = "", restoreConsole = TRUE)
width, height |
the (nominal) width and height of the canvas of the plotting window in inches. |
pointsize |
the default pointsize of plotted text. Values are rounded to the nearest integer: values less than or equal to zero are reset to 12. |
record |
logical: sets the initial state of the flag for recording plots. |
rescale |
controls the action for resizing plots. |
xpinch, ypinch |
double. Pixels per inch, horizontally and vertically. |
bg |
color. The default background color. |
canvas |
color. The color of the canvas which is visible when the background color is transparent. |
gamma |
the gamma correction factor. This value is used
to ensure that the colors perceived are linearly related to
RGB values (see hsv ). By default this is taken from
options("gamma") , or is 1 (no correction) if that is
unset (the usual case). |
xpos, ypos |
integer. Position of the top left of the window, in
pixels. Negative values are taken from the opposite edge of the
monitor. Missing values meant take the default from the
‘Rconsole’ file, which in turn defaults to
xpos=-25, ypos=0 : this puts the right edge of the window 25
pixels from the right edge of the monitor. |
buffered |
logical. Should the screen output be double-buffered? |
filename |
the name of the output file: it will be an enhanced
Windows metafile, usually given extension .emf or
.wmf . Up to 511 characters are allowed.
The page number is substituted if an integer format is included
in the character string. (The result must be less than 600
characters long.) The default, "" , means the clipboard.
|
printer |
The name of a printer as known to Windows. The default causes a dialog box to come for the user to choose a printer. |
restoreConsole |
logical: see the Details below. |
All these devices are implemented as windows
devices, the
display
parameter selects which is actually used.
The size of a window is computed from information provided about the
display: it depends on the system being configured accurately.
By default a screen device asks Windows for the number of pixels per
inch. This can be overridden (it is often wrong) by specifying
xpinch
and ypinch
or the corresponding options
"xpinch"
and "ypinch"
.
A graphics window is not allowed to be specified at more that 85% of the screen width or height: the width and height are rescaled proportionally. The window can be resized to a larger size. In MDI mode, the limit is 85% of the MDI client region.
If the filename
is omitted for a win.metafile
device, the
output is copied to the clipboard when the device is closed.
If a screen device is re-sized, the default behaviour is to redraw the
plot(s) as if the new size had been specified originally. Using
"fit"
will rescale the existing plot(s) to fit the new device
region, preserving the aspect ratio. Using "fixed"
will leave
the plot size unchanged, adding scrollbars if part of the
plot is obscured.
A graphics window will never be created at more that 85% of
the screen width or height, but can be resized to a larger size.
For the first two rescale
options the width and height are
rescaled proportionally if necessary, and if rescale = "fit"
the plot(s) are rescaled accordingly. If rescale = "fixed"
the initially displayed portion is selected within these constraints,
separately for width and height.
Using strwidth
or strheight
after a window
has been rescaled (when using "fit"
) gives dimensions in the
original units, but only approximately as they are derived from the
metrics of the rescaled fonts (which are in integer sizes)
The displayed region may be bigger than the ‘paper’ size, and
areas outside the ‘paper’ are coloured in the Windows
application background colour. Graphics parameters such as
"din"
refer to the scaled plot if rescaling is in effect.
The different colours need to be distinguished carefully. The area outside the device region is coloured in the Windows application background colour. The device region is coloured in the canvas colour. This is over-painted by the background colour of a plot when a new page is called for, but that background colour can be transparent (and is by default). The difference between setting the canvas colour and the background colour is that when the device is copied the background colour is copied but the canvas colour is not.
Recorded plot histories are of class "SavedPlots"
. They have a
print
method, and a subset method. As the individual plots are
of class "recordedplot"
they can be replayed by printing them:
see recordPlot
. The active plot history is stored in
variable .SavedPlots
in the workspace.
When a screen device is double-buffered (the default) the
screen is updated 100ms after last plotting call or every 500ms during
continuous plotting. These times can be altered by setting
options("windowsTimeout")
to a vector of two integers before
opening the device.
The font used for text drawn in a Windows device may be controlled in
two ways. The file RHOME\etc\Rdevga
can be used to specify
mappings for par(font=)
(in the graphics package). Alternatively,
a device-independent R graphics font family can be specified (e.g.,
via par(family=)
in the graphics package) and this will be
mapped via the Windows font database (see windowsFonts
).
Line widths as controlled by par(lwd=)
are in multiples of
1/96inch. Multiples less than 1 are allowed, down to one pixel width.
pch="."
with cex = 1
corresponds to a rectangle of sides
the larger of one pixel and 0.01 inch.
For win.metafile
only one plot is allowed per file, and Windows
seems to disallow reusing the file. So the only way to allow
multiple plots is to use a parametrized filename
as in the example.
The restoreConsole
argument is a temporary fix for a problem
in the current implementation of several Windows graphics devices,
and is likely to be removed in an upcoming release. If set to
FALSE
, the console will not receive the focus after the new
device is opened.
A plot device is opened: nothing is returned to the R interpreter.
windowsFonts
,
savePlot
, bringToTop
,
Devices
, postscript
## Not run: ## A series of plots written to a sequence of metafiles win.metafile("Rplot%02d.wmf", pointsize = 10) ## End(Not run)