[R] gray background on jpegs using dev.print()
John Muller
jmuller at mindspring.com
Thu Apr 1 21:36:36 CEST 2004
Sorry about the email issue. I have a spam filter that only let's things on
my "pass" list into my Inbox, all else gets put into a "suspect" folder.
I have added the R help list to my pass list.
Prof. Ripley asked
>> why if you are using Windows *are* you using dev.print
I actually started by using the function HTMLplot
from the the R2HTML package. Was getting this gray background problem
so I looked at the code for that and saw that it was calling dev.print
... so that's why I started using it. Did not know there was a savePlot function.
Will use that now.
Not sure if that is still relevant, but here is a short sequence of commands
that reproduces the issue for me
> palette(rainbow(4)) ;
> plot(1:10) ;
> dev.print(jpeg,file="c:/test1.jpeg",width=500,height=500,bg="white") ;
> savePlot(file="C:/test2",type=c("jpeg"));
For me, this products 2 jpeg files,
test1.jpeg which has a gray background
and
test2.jpeg which has a white background
Seems that the palette is related to the gray background with dev.print.
Not sure if it is possible to reset the palette after the plot to get around
the issue, and not really important to me now since I know about the savePlot
function. Just thought some of you might want to know.
Thanks again for all the helpful and encouraging responses, especially Dr. Ripley.
- john muller
-----Original Message-----
From: Prof Brian Ripley <ripley at stats.ox.ac.uk>
Sent: Apr 1, 2004 11:54 AM
To: John Muller <jmuller at mindspring.com>
Cc: r-help at stat.math.ethz.ch
Subject: Re: [R] gray background on jpegs using dev.print()
On Thu, 1 Apr 2004, John Muller wrote:
> When I try writing the current device to a jpeg file I keep getting a
> gray background for the jpeg images using dev.print.
That's because you are not using the correct tool. dev.print is designed
for printing, as it says.
> I have tried using the option bg="white" and bg="#FFFFFF"
> but neither seem to have any effect.
Where? Is what you are copying on a transparent background (the default)?
> If instead of writing to a screen device I open a jpeg device I can get any background color
> I want. This works, but I prefer to write to the screen and then
> output to file if I like the results rather than to a file and have to view the jpegs
> to see results.
>
> I am using R version 1.8.1 on Windows 2000.
>
> Has anyone else had this problem?
What problem, exactly ...? Please do read the posting guide and supply
enough details for us to reproduce this.
And why if you are using Windows *are* you using dev.print when you are
not printing and there are menus and savePlot to copy a plot to a jpeg
file?
--
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