Hi while teaching R, the question came up if it would be possible to add a picture (saved on the HDD) to a graph (generated by plot()), which we could not answer. It might easily kill a clean graph, but: is there a way of doing this, even one should not do it? On a similar line of thought: is it possibe to define own symbols so that they can be used in the plot function with pch=? Rainer -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa
See: http://wiki.r-project.org/rwiki/doku.php?id=tips:graphics-misc:translucency On Wed, Jul 29, 2009 at 4:27 AM, Rainer M Krug<r.m.krug at gmail.com> wrote:> Hi > > while teaching R, the question came up if it would be possible to add > a picture (saved on the HDD) to a graph (generated by plot()), which > we could not answer. > > > > It might easily kill a clean graph, but: is there a way of doing this, > even one should not do it? > > > On a similar line of thought: is it possibe to define own symbols so > that they can be used in the plot function with pch=? > > > Rainer > > -- > Rainer M. Krug, Centre of Excellence for Invasion Biology, > Stellenbosch University, South Africa > > ______________________________________________ > 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. >
I had to do this recently, and I finally gave up trying to do it with R alone. Instead, I used the LaTeX overpic package. For the result, see Figure 1 in http://journal.sjdm.org/9417/jdm9417.pdf or (screenshot of it) in http://journal.sjdm.org/9417/jdm9417.html and the .tex file http://journal.sjdm.org/9417/jdm9417.tex and the R file that drew the plots http://journal.sjdm.org/9417/figs.R The pictures are tiny in this case. I do think it is possible to define your own symbols. Maybe someone else can say how. Jon On 07/29/09 10:27, Rainer M Krug wrote:> Hi > > while teaching R, the question came up if it would be possible to add > a picture (saved on the HDD) to a graph (generated by plot()), which > we could not answer. > > > > It might easily kill a clean graph, but: is there a way of doing this, > even one should not do it? > > > On a similar line of thought: is it possibe to define own symbols so > that they can be used in the plot function with pch=? > > > Rainer > > -- > Rainer M. Krug, Centre of Excellence for Invasion Biology, > Stellenbosch University, South Africa > > ______________________________________________ > 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.-- Jonathan Baron, Professor of Psychology, University of Pennsylvania Home page: http://www.sas.upenn.edu/~baron Editor: Judgment and Decision Making (http://journal.sjdm.org)
Hi Rainer,>> the question came up if it would be possible to add a picture >> (saved on the HDD) to a graph (generated by plot()), which >> we could not answer.Yes. Look at package pixmap and, especially, at the examples sub s.logo() in package ade4. Regards, Mark. Rainer M Krug-6 wrote:> > Hi > > while teaching R, the question came up if it would be possible to add > a picture (saved on the HDD) to a graph (generated by plot()), which > we could not answer. > > > > It might easily kill a clean graph, but: is there a way of doing this, > even one should not do it? > > > On a similar line of thought: is it possibe to define own symbols so > that they can be used in the plot function with pch=? > > > Rainer > > -- > Rainer M. Krug, Centre of Excellence for Invasion Biology, > Stellenbosch University, South Africa > > ______________________________________________ > 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. > >-- View this message in context: http://www.nabble.com/Adding-picture-to-graph--tp24714724p24716913.html Sent from the R help mailing list archive at Nabble.com.
Have a look at http://www.stat.auckland.ac.nz/~paul/RGraphics/chapter3.html Picture 3.26 Thomas Roth Rainer M Krug schrieb:> Hi > > while teaching R, the question came up if it would be possible to add > a picture (saved on the HDD) to a graph (generated by plot()), which > we could not answer. > > > > It might easily kill a clean graph, but: is there a way of doing this, > even one should not do it? > > > On a similar line of thought: is it possibe to define own symbols so > that they can be used in the plot function with pch=? > > > Rainer > >
several options are listed here: http://wiki.r-project.org/rwiki/doku.php?id=tips:graphics-misc:display-images baptiste> > Rainer M Krug schrieb: >> >> Hi >> >> while teaching R, the question came up if it would be possible to add >> a picture (saved on the HDD) to a graph (generated by plot()), which >> we could not answer. >> >> >> >> It might easily kill a clean graph, but: is there a way of doing this, >> even one should not do it? >> >> >> On a similar line of thought: is it possibe to define own symbols so >> that they can be used in the plot function with pch=? >> >> >> Rainer >> >> >
I'm not sure if you can consider grid graphics. If so, then Murrell has some nice worked examples in: http://www.stat.auckland.ac.nz/~paul/Talks/gddg.pdf On Jul 29, 2009, at 4:27 AM, Rainer M Krug wrote:> while teaching R, the question came up if it would be possible to add > a picture (saved on the HDD) to a graph (generated by plot()), which > we could not answer. > > It might easily kill a clean graph, but: is there a way of doing this, > even one should not do it? > > On a similar line of thought: is it possibe to define own symbols so > that they can be used in the plot function with pch=? > > Rainer > -- > Rainer M. Krug, Centre of Excellence for Invasion Biology, > Stellenbosch University, South AfricaDavid Winsemius, MD Heritage Laboratories West Hartford, CT
In addition to the other responses, you may want to look at the subplot function in the TeachingDemos package for a way to place the image at a location within the plot (the other answers so far use the image as a full background), see the last example on the help page for a way to use the R logo as a plotting symbol. If you want to define your own symbols for plotting, look at the my.symbols function in the TeachingDemos package. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Rainer M Krug > Sent: Wednesday, July 29, 2009 2:27 AM > To: r-help at stat.math.ethz.ch > Subject: [R] Adding picture to graph? > > Hi > > while teaching R, the question came up if it would be possible to add > a picture (saved on the HDD) to a graph (generated by plot()), which > we could not answer. > > > > It might easily kill a clean graph, but: is there a way of doing this, > even one should not do it? > > > On a similar line of thought: is it possibe to define own symbols so > that they can be used in the plot function with pch=? > > > Rainer > > -- > Rainer M. Krug, Centre of Excellence for Invasion Biology, > Stellenbosch University, South Africa > > ______________________________________________ > 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.
Rainer M Krug-6 wrote:> > Hi > > while teaching R, the question came up if it would be possible to add > a picture (saved on the HDD) to a graph (generated by plot()), which > we could not answer. > > > > It might easily kill a clean graph, but: is there a way of doing this, > even one should not do it? > > > On a similar line of thought: is it possibe to define own symbols so > that they can be used in the plot function with pch=? > > > Rainer > > -- > Rainer M. Krug, Centre of Excellence for Invasion Biology, > Stellenbosch University, South Africa > > ______________________________________________ > 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. > >See our "Beginner's Guide to R" for an example; a time series of the date the penguins lay eggs is plotted, and a jpg with penguins is used as background. The code is on the book's website at: www.highstat.com(follow the link to the R book). It was quite a challenge to do this...not because of the R code (we used Murrel, 2006)...but because of figuring out the optimal the size of the jpg. R didn't like to use the original 5Mb jpg file. So..I had to reduce it size. Alain Zuur ----- -------------------------------------------------------------------- Dr. Alain F. Zuur First author of: 1. Analysing Ecological Data (2007). Zuur, AF, Ieno, EN and Smith, GM. Springer. 680 p. 2. Mixed effects models and extensions in ecology with R. (2009). Zuur, AF, Ieno, EN, Walker, N, Saveliev, AA, and Smith, GM. Springer. 3. A Beginner's Guide to R (2009). Zuur, AF, Ieno, EN, Meesters, EHWG. Springer Statistical consultancy, courses, data analysis and software Highland Statistics Ltd. 6 Laverock road UK - AB41 6FN Newburgh Email: highstat at highstat.com URL: www.highstat.com -- View this message in context: http://www.nabble.com/Adding-picture-to-graph--tp24714724p24736042.html Sent from the R help mailing list archive at Nabble.com.