When I am plotting, I often plot to an eps
file and a png
file like this:
postscript(file=paste(dir, output, "_ggplot.eps", sep=""), onefile=FALSE, horizontal=FALSE, width=4.8, height=4.0)
# Plotting code
dev.off()
png(paste(dir, output, "_ggplot.png", sep=""), width=450, height=300)
# Plotting code
dev.off()
The problem is that the plotting code is repeated twice. Is it possible to specify multiple devices for plotting?
We can put multiple graphs in a single plot by setting some graphical parameters with the help of par() function. R programming has a lot of graphical parameters which control the way our graphs are displayed. The par() function helps us in setting or inquiring about these parameters.
The Direct Graphics system in IDL offers a variety of ways to create plots of your data. Two-dimensional graph types include line, scatter, polar, bar, histogram, and contour plots.
dev. off shuts down the specified (by default the current) device. If the current device is shut down and any other devices are open, the next open device is made current.
As you might have guessed, every open graphics device is assigned an integer greater than or equal to 2. You can change the active graphics device with dev.
You can combine them using dev.copy()
. For example,
X11 ()
plot (x,y)
dev.copy (jpeg,filename="test.jpg");
dev.off ();
Lookup help(dev.copy)
for more details.
Usage:
dev.copy(device, ..., which = dev.next())
dev.print(device = postscript, ...)
dev.copy2eps(...)
dev.copy2pdf(..., out.type = "pdf")
dev.control(displaylist = c("inhibit", "enable"))
No it's not possible. At least not according to the manual for ?grDevices
:
"Details: Only one device is the ‘active’ device: this is the device in which all graphics operations occur. There is a "null device" which is always open but is really a placeholder: any attempt to use it will open a new device specified by getOption("device"))."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With