Hi Im trying to save a plot both to a pdf and as just a picture but without success so if someone can help me I would be happy :) my code: require(party) irisct <- ctree(Species ~ .,data = iris) data(iris) attach(iris) pdf('/home/joel/Skrivbord/mammamu.pdf') try(png('/home/joel/Skrivbord/mammamu1.png')) plot(Sepal.Length, Petal.Length, col=unclass(Species)) legend(4.5, 7, levels(Species), col=plot_colors, cex=0.8, fill=1:3) try(png('/home/joel/Skrivbord/mammamu2.png')) plot(irisct) dev.off() readBin(pic,'raw',1024*1024) readBin('/home/joel/Skrivbord/mammamu2.png','raw',1024*1024) Ive tryed to move around the png and pdf part to see if it worked better if they where in an other order but as I said without success. //Joel -- View this message in context: http://r.789695.n4.nabble.com/Saveing-plot-to-multiple-locations-tp2537133p2537133.html Sent from the R help mailing list archive at Nabble.com.
On 09/13/2010 11:32 AM, Joel wrote:> Hi > Im trying to save a plot both to a pdf and as just a picture but without > success so if someone can help me I would be happy :) >The problem is that the plot goes only to one graphics device, the last one you defined. Just make the plot twice: pdf("bla.pdf") plot(bla) dev.off() png("bla.png") plot(bla) dev.off() cheers, Paul> my code: > > require(party) > irisct<- ctree(Species ~ .,data = iris) > data(iris) > attach(iris) > pdf('/home/joel/Skrivbord/mammamu.pdf') > try(png('/home/joel/Skrivbord/mammamu1.png')) > plot(Sepal.Length, Petal.Length, col=unclass(Species)) > legend(4.5, 7, levels(Species), col=plot_colors, cex=0.8, fill=1:3) > try(png('/home/joel/Skrivbord/mammamu2.png')) > plot(irisct) > dev.off() > readBin(pic,'raw',1024*1024) > readBin('/home/joel/Skrivbord/mammamu2.png','raw',1024*1024) > > Ive tryed to move around the png and pdf part to see if it worked better if > they where in an other order but as I said without success. > > //Joel >-- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 253 5773 http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
On Sep 13, 2010, at 5:32 AM, Joel wrote:> > Hi > Im trying to save a plot both to a pdf and as just a picture but > without > success so if someone can help me I would be happy :)Are you trying to embed a png file in a graphic or do you just want two different files? If the first (obviously the more difficult) then Paul Murrell has a bunch of material he has offered over the years: cran.r-project.org/web/packages/grImport/vignettes/import.pdf Vector graphics is the focus but citations to packages handling raster or bitmap graphics are included. If it is the second, then just do one task, complete it with dev.off(), which is needed to close the file, and move on to the other. -- David> > my code: > > require(party) > irisct <- ctree(Species ~ .,data = iris) > data(iris) > attach(iris) > pdf('/home/joel/Skrivbord/mammamu.pdf') > try(png('/home/joel/Skrivbord/mammamu1.png')) > plot(Sepal.Length, Petal.Length, col=unclass(Species)) > legend(4.5, 7, levels(Species), col=plot_colors, cex=0.8, fill=1:3) > try(png('/home/joel/Skrivbord/mammamu2.png')) > plot(irisct) > dev.off() > readBin(pic,'raw',1024*1024) > readBin('/home/joel/Skrivbord/mammamu2.png','raw',1024*1024) > > Ive tryed to move around the png and pdf part to see if it worked > better if > they where in an other order but as I said without success. > > //Joel > -- > View this message in context: http://r.789695.n4.nabble.com/Saveing-plot-to-multiple-locations-tp2537133p2537133.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.David Winsemius, MD West Hartford, CT