Is it possible to save plots as byte streams? For example, if I want the
bytes for a PNG plot, I could use
#Write the plot to a PNG file
png("test.png")
plot(1:10)
dev.off()
#Read the bytes back in from the file
plotbytes <- readBin("test.png", "raw", n=2000)
Ideally, I'd like to avoid having to bother writing to the file in the
first place, and simply store the bytes in a variable. How do I do this?
Regards,
Richie.
Mathematical Sciences Unit
HSL
------------------------------------------------------------------------
ATTENTION:
This message contains privileged and confidential inform...{{dropped:20}}
Saving plots as byte streams
2 messages · Richard Cotton, Brian Ripley
On Fri, 9 Jan 2009, Richard.Cotton at hsl.gov.uk wrote:
Is it possible to save plots as byte streams?
You mean bitmap plots? E.g. PDF plots are not even written sequentially.
For example, if I want the
bytes for a PNG plot, I could use
#Write the plot to a PNG file
png("test.png")
plot(1:10)
dev.off()
#Read the bytes back in from the file
plotbytes <- readBin("test.png", "raw", n=2000)
Ideally, I'd like to avoid having to bother writing to the file in the
first place, and simply store the bytes in a variable. How do I do this?
The bitmap library interfaces which we use write to files, so there is no way to do this short of rewriting all the bitmap code. If there had been, they would be writing to connections already.
Regards, Richie. Mathematical Sciences Unit HSL
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595