Description Usage Arguments Details Value Side Effects Author(s) See Also Examples
Utilities to make graphing in Rpad R scripts easier.
1 2 3 |
reset, override.check |
logical arguments passed to |
name |
is the name of the graph with the extension left OFF. |
link |
is a logical specifying whether to show a link to allow the user to download an EPS file of the graph (not available when using R's png driver. |
... |
named arguments assigned as defaults for |
The graphoptions
, newgraph
, and showgraph
set of functions allows quick setup and display of web-friendly graphics.
In an Rpad page, the user can normally just use any of the plot commands followed by showgraph
.
newgraph
sets up the graphics device, and it's called when the Rpad package starts.
showgraph
generates the HTML to show the graph and runs newgraph
to advance to the next graphics file.
Graphics files are by default named Rpad\_plot1, Rpad\_plot2, and so on.
Named graphs can also be used, but there's more of a chance that if the user has caching set wrong (or the server's caching is set wrong) that graphs won't update properly in the user's browser.
With the default sequential numbering of files, caching problems are less likely.
Internally, newgraph
uses one of two devices to generate the bitmap for the browser.
Specifying type="Rpng"
directs newgraph
to use R's png
device directly.
The type="pngalpha"
option outputs to a postscript
device, followed by ghostscript conversion to PNG with anti-aliasing.
This approach has the side-effect of creating an EPS file for each graph, so it's easy to add a link to allow the user to download the EPS file.
graphoptions
is available to change the parameters from their defaults.
It can be called interactively (before running Rpad()
) or in the server version (in RpadStartup.R).
extension
is the file extension of the device (typically '.png').
type
is the graphics device, either a ghostscript device as a
character string, or "Rpng" for R's builtin png device.
For a ghostscript device, common
possibilities are "png256", "pngalpha" (the default), or "pdf".
res
is the resolution of the bitmap in dots per inch.
width
, height
are the dimensions of the graph in inches.
deviceUsesPixels
is a logical specifying whether the R
graphics driver uses pixels. This only applies if type
is
used to specify an R graphics driver. It defaults to TRUE.
ratio
specifies the ratio of the graph if either the width or
height is not specified.
pointsize
is the font point size passed to the postscript
device.
sublines
, toplines
, leftlines
specify the dimension of
the graph along with the outside border. It defaults to fairly tight
outside dimensions.
lwd
is the line width set with par
.
None of the routines returns a value: all are run for their side effects.
newgraph
opens a new graphics device, saving files with the pattern Rpad_plot.*.png (and Rpad_plot.*.eps for pngalpha) in the working directory.
Tom Short, EPRI, (tshort@epri.com)
See also bitmap
, png
, and pdf
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # make some graphs (a default graphics device is already available)
x <- 1:10
y <- x^2
y2 <- x^3
if (capabilities("png")) graphoptions(type="Rpng")
newgraph()
plot(x, y) # does the plot
plot(x, y2) # does the second plot
HTMLon() # sets Rpad to HTML output
showgraph() # closes the device, outputs the HTML for the both
# images, and creates the next device
plot(x, y2)
showgraph()
# graphs with named files:
newgraph("graph_A")
plot(x, y)
showgraph("graph_A")
# also adjust the width and height
graphoptions(width = 4, height = 6)
newgraph("graph_B")
plot(x, y2)
showgraph("graph_B")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.