[R] Problems exporting graphs
Prof Brian Ripley
ripley at stats.ox.ac.uk
Fri Jun 27 18:01:55 CEST 2008
On Fri, 27 Jun 2008, stephen sefick wrote:
> pdf( "yourfile.pdf", height=22, width=17)
> #yourcode
> dev.off()
>
> then use the gimp (free) to transform it to .png or whatever else (pdf makes
> good graph)
So do R's graphics devices ....
If you do want to convert PDF to PNG there are much better ways than the
GIMP based on ghostscript, including R's bitmap() device.
>
> On Thu, Jun 26, 2008 at 8:59 PM, Daniel Folkinshteyn <dfolkins at gmail.com>
> wrote:
>
>> not sure why it doesn't work, but try the following:
>> first, plot to a regular window, then run:
>>> dev.copy(device=png, file="yourfilename.png")
>>> dev.off()
>>
>> see if that produces a file you want.
>>
>> another note: what do you mean you can't just "copy and paste the graph" in
>> ubuntu? doesn't pressing print-screen make a screenshot? doesn't pressing
>> alt-printscreen make a screenshot of the current active window? (or even
>> from the main menu, "applications-> accessories -> take screenshot" should
>> work).
>>
>> on 06/26/2008 08:43 PM Sam Albers said the following:
>>
>> I have trying to figure this out all day so hopefully the answer isn't too
>>> obvious. I am able to view a graph in the viewer window. However, I need
>>> to
>>> export graph outside of the viewer window. Here is the script I am using:
>>>
>>> png("Compare.png")
>>>> plot(compare$DepthSLI, compare$DischargeSLI, col="blue", xlab = "Average
>>>>
>>> Water Depth (cm)", ylab = "Discharge (m^3/s)", xlim=c(5,40),
>>> ylim=c(0.03,0.1), main="Discharge in Flume 1")
>>>
>>>> dev.off()
>>>>
>>> null device
>>> 1
>>>
>>> When I do this R simply produces an empty file that produces an error
>>> message when I try to open it. I have tried this same script with every
>>> file
>>> format available under help(device) all with the same result. I am running
>>> Ubuntu 8.04 so I unable to simply copy and paste the graph as in windows.
>>> I
>>> am fairly sure I have all the right packages installed. I am running R
>>> 2.6.2-2. Any suggestions?
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> R-help at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
> --
> Let's not spend our time and resources thinking about things that are so
> little or so large that all they really do for us is puff us up and make us
> feel like gods. We are mammals, and have not exhausted the annoying little
> problems of being mammals.
>
> -K. Mullis
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
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
More information about the R-help
mailing list