When I try writing the current device to a jpeg file I keep getting a gray background for the jpeg images using dev.print. I have tried using the option bg="white" and bg="#FFFFFF" but neither seem to have any effect. 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? If so please let me know, especially if you found a better workaround or a fix. - john muller
You have not shown us how you call dev.print() or the commands preceding that. Did you specify the bg="white" in the call to dev.print()? Andy> From: John Muller > > When I try writing the current device to a jpeg file I keep > getting a gray background > for the jpeg images using dev.print. > > I have tried using the option bg="white" and bg="#FFFFFF" > but neither seem to have any effect. > > 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? > If so please let me know, especially if you found a better > workaround or a fix. > > - john muller > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > >------------------------------------------------------------------------------ Notice: This e-mail message, together with any attachments,...{{dropped}}
I get the gray background when I use plot to write to the screen and then try to write the screen contents to a file using dev.print(jpeg, file="H:/Secondary/cycle_time/test.jpg",width=800,quality=100,bg="white") ; I have also tried using bg = "#FFFFFF" instead of bg="white" and have also tried using par to set the background color as in par(bg="#FFFFFF") ; dev.print(jpeg, file="H:/Secondary/cycle_time/test.jpg",width=800,quality=100,bg="white") ; None of these seem to affect the background color of the jpeg image. - john -----Original Message----- From: John Muller <jmuller at mindspring.com> Sent: Apr 1, 2004 11:05 AM To: r-help at stat.math.ethz.ch Subject: gray background on jpegs using dev.print() When I try writing the current device to a jpeg file I keep getting a gray background for the jpeg images using dev.print. I have tried using the option bg="white" and bg="#FFFFFF" but neither seem to have any effect. 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? If so please let me know, especially if you found a better workaround or a fix. - john muller
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
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.printI 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