Re: [R] Positioning text in top left corner of plot
Jim Lemon wrote: > Daniel Brewer wrote: >> Thanks for the replies, but I still cannot get what I want. I do not >> want the label inside the plot area, but in the top left of the paper, I >> suppose in the margins. When I try to use text to do this, it does not >> seem to plot it outside the plot area. I have also tried to use mtext, >> but that does not really cut it, as I cannot get the label in the >> correct position. Ideally, it would be best if I could use legend but >> have it outside the plot area. >> >> Any ideas? >> > Hi Dan, > > Try this: > > plot(1:5) > par(xpd=TRUE) > text(0.5,5.5,"Outside") > par(xpd=FALSE) > > Jim Here is what I used in the end: par(xpd=T) text(-0.15*(par("usr")[2]-par("usr")[1]),par("usr")[4]+0.14*(par("usr")[4]-par("usr")[3]),labels[i],cex=1.5) par(xpd=F) Ans that worked a treat. Thanks Dan -- ** Daniel Brewer, Ph.D. Institute of Cancer Research Email: [EMAIL PROTECTED] ** The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company Limited by Guarantee, Registered in England under Company No. 534147 with its Registered Office at 123 Old Brompton Road, London SW7 3RP. This e-mail message is confidential and for use by the addre...{{dropped}} __ R-help@stat.math.ethz.ch 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.
Re: [R] Positioning text in top left corner of plot
Thanks. That works if it is only a single plot, but if there are multiple plots (e.g. par(mfrow=c(2,2))) it confusingly puts the label in the absolute top left always i.e. the top left of plot one. Dan S Ellison wrote: > Try something like > mtext(side=3, line=-1, text="Here again?", adj=0, outer=T) > > This puts text just inside the top left corner. > > Jim Lemon <[EMAIL PROTECTED]> 10/08/2007 10:37:30 >>> > Daniel Brewer wrote: >> Thanks for the replies, but I still cannot get what I want. I do not >> want the label inside the plot area, but in the top left of the paper, I >> suppose in the margins. When I try to use text to do this, it does not >> seem to plot it outside the plot area. I have also tried to use mtext, >> but that does not really cut it, as I cannot get the label in the >> correct position. Ideally, it would be best if I could use legend but >> have it outside the plot area. >> >> Any ideas? >> > Hi Dan, > > Try this: > > plot(1:5) > par(xpd=TRUE) > text(0.5,5.5,"Outside") > par(xpd=FALSE) > > Jim The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company Limited by Guarantee, Registered in England under Company No. 534147 with its Registered Office at 123 Old Brompton Road, London SW7 3RP. This e-mail message is confidential and for use by the addre...{{dropped}} __ R-help@stat.math.ethz.ch 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.
Re: [R] Positioning text in top left corner of plot
This works fine for one plot, but if it is a multiple plot (mfrow=c(2,2) say) then each individual label is placed in the same position i.e. absolute top left on the canvas. I would like it top left of each individual plot. Thanks anyway. Got any idea how to fix this? Dan Paul Murrell wrote: > Hi > > > Daniel Brewer wrote: >> Thanks for the replies, but I still cannot get what I want. I do not >> want the label inside the plot area, but in the top left of the paper, I >> suppose in the margins. When I try to use text to do this, it does not >> seem to plot it outside the plot area. I have also tried to use mtext, >> but that does not really cut it, as I cannot get the label in the >> correct position. Ideally, it would be best if I could use legend but >> have it outside the plot area. >> >> Any ideas? > > > plot(1:10) > library(grid) > grid.text("What do we want? Text in the corner!\nWhere do we want it? > Here!", > x=unit(2, "mm"), y=unit(1, "npc") - unit(2, "mm"), > just=c("left", "top")) > > Paul > > >> Thanks >> >> Benilton Carvalho wrote: >>> maybe this is what you want? >>> >>> plot(rnorm(10)) >>> legend("topleft", "A)", bty="n") >>> >>> ? >>> >>> b >>> >>> On Aug 7, 2007, at 11:08 AM, Daniel Brewer wrote: >>> Simple question how can you position text in the top left hand corner of a plot? I am plotting multiple plots using par(mfrow=c(2,3)) and all I want to do is label these plots a), b), c) etc. I have been fiddling around with both text and mtext but without much luck. text is fine but each plot has a different scale on the axis and so this makes it problematic. What is the best way to do this? Many thanks Dan > > The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company Limited by Guarantee, Registered in England under Company No. 534147 with its Registered Office at 123 Old Brompton Road, London SW7 3RP. This e-mail message is confidential and for use by the addre...{{dropped}} __ R-help@stat.math.ethz.ch 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.
Re: [R] Positioning text in top left corner of plot
Hi Daniel Brewer wrote: > Thanks for the replies, but I still cannot get what I want. I do not > want the label inside the plot area, but in the top left of the paper, I > suppose in the margins. When I try to use text to do this, it does not > seem to plot it outside the plot area. I have also tried to use mtext, > but that does not really cut it, as I cannot get the label in the > correct position. Ideally, it would be best if I could use legend but > have it outside the plot area. > > Any ideas? plot(1:10) library(grid) grid.text("What do we want? Text in the corner!\nWhere do we want it? Here!", x=unit(2, "mm"), y=unit(1, "npc") - unit(2, "mm"), just=c("left", "top")) Paul > Thanks > > Benilton Carvalho wrote: >> maybe this is what you want? >> >> plot(rnorm(10)) >> legend("topleft", "A)", bty="n") >> >> ? >> >> b >> >> On Aug 7, 2007, at 11:08 AM, Daniel Brewer wrote: >> >>> Simple question how can you position text in the top left hand corner of >>> a plot? I am plotting multiple plots using par(mfrow=c(2,3)) and all I >>> want to do is label these plots a), b), c) etc. I have been fiddling >>> around with both text and mtext but without much luck. text is fine but >>> each plot has a different scale on the axis and so this makes it >>> problematic. What is the best way to do this? >>> >>> Many thanks >>> >>> Dan -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 [EMAIL PROTECTED] http://www.stat.auckland.ac.nz/~paul/ __ R-help@stat.math.ethz.ch 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.
Re: [R] Positioning text in top left corner of plot
Daniel Brewer wrote: > Thanks for the replies, but I still cannot get what I want. I do not > want the label inside the plot area, but in the top left of the paper, I > suppose in the margins. When I try to use text to do this, it does not > seem to plot it outside the plot area. I have also tried to use mtext, > but that does not really cut it, as I cannot get the label in the > correct position. Ideally, it would be best if I could use legend but > have it outside the plot area. > > Any ideas? > Hi Dan, Try this: plot(1:5) par(xpd=TRUE) text(0.5,5.5,"Outside") par(xpd=FALSE) Jim __ R-help@stat.math.ethz.ch 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.
Re: [R] Positioning text in top left corner of plot
Thanks for the replies, but I still cannot get what I want. I do not want the label inside the plot area, but in the top left of the paper, I suppose in the margins. When I try to use text to do this, it does not seem to plot it outside the plot area. I have also tried to use mtext, but that does not really cut it, as I cannot get the label in the correct position. Ideally, it would be best if I could use legend but have it outside the plot area. Any ideas? Thanks Benilton Carvalho wrote: > maybe this is what you want? > > plot(rnorm(10)) > legend("topleft", "A)", bty="n") > > ? > > b > > On Aug 7, 2007, at 11:08 AM, Daniel Brewer wrote: > >> Simple question how can you position text in the top left hand corner of >> a plot? I am plotting multiple plots using par(mfrow=c(2,3)) and all I >> want to do is label these plots a), b), c) etc. I have been fiddling >> around with both text and mtext but without much luck. text is fine but >> each plot has a different scale on the axis and so this makes it >> problematic. What is the best way to do this? >> >> Many thanks >> >> Dan -- ** Daniel Brewer, Ph.D. Institute of Cancer Research Email: [EMAIL PROTECTED] ** The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company Limited by Guarantee, Registered in England under Company No. 534147 with its Registered Office at 123 Old Brompton Road, London SW7 3RP. This e-mail message is confidential and for use by the addre...{{dropped}} __ R-help@stat.math.ethz.ch 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.
Re: [R] Positioning text in top left corner of plot
maybe this is what you want? plot(rnorm(10)) legend("topleft", "A)", bty="n") ? b On Aug 7, 2007, at 11:08 AM, Daniel Brewer wrote: > Simple question how can you position text in the top left hand > corner of > a plot? I am plotting multiple plots using par(mfrow=c(2,3)) and > all I > want to do is label these plots a), b), c) etc. I have been fiddling > around with both text and mtext but without much luck. text is > fine but > each plot has a different scale on the axis and so this makes it > problematic. What is the best way to do this? > > Many thanks > > Dan > -- > ** > Daniel Brewer, Ph.D. > > Institute of Cancer Research > Email: [EMAIL PROTECTED] > ** > > The Institute of Cancer Research: Royal Cancer Hospital, a > charitable Company Limited by Guarantee, Registered in England > under Company No. 534147 with its Registered Office at 123 Old > Brompton Road, London SW7 3RP. > > This e-mail message is confidential and for use by the add...{{dropped}} __ R-help@stat.math.ethz.ch 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.
Re: [R] Positioning text in top left corner of plot
You can call par('usr') to find the current coordinates, then use the text function (the pos and offset arguments may be helpful as well) The cnvrt.coords function from the TeachingDemos package may also be of help for finding coordinates for the text function. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Daniel Brewer > Sent: Tuesday, August 07, 2007 9:09 AM > To: r-help@stat.math.ethz.ch > Subject: [R] Positioning text in top left corner of plot > > Simple question how can you position text in the top left > hand corner of a plot? I am plotting multiple plots using > par(mfrow=c(2,3)) and all I want to do is label these plots > a), b), c) etc. I have been fiddling around with both text > and mtext but without much luck. text is fine but each plot > has a different scale on the axis and so this makes it > problematic. What is the best way to do this? > > Many thanks > > Dan > -- > ** > Daniel Brewer, Ph.D. > > Institute of Cancer Research > Email: [EMAIL PROTECTED] > ** > > The Institute of Cancer Research: Royal Cancer Hospital, a > charitable Company Limited by Guarantee, Registered in > England under Company No. 534147 with its Registered Office > at 123 Old Brompton Road, London SW7 3RP. > > This e-mail message is confidential and for use by the\ > ...{{dropped}} __ R-help@stat.math.ethz.ch 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.