[R] expression() - Superscript in y-axis, keeping line break in string
I've tried several different ways to accomplish this, but as yet to no avail. My y-axis for a plot has a rather long label, and thus I have been using /n to break it into two lines. However, to make it technically correct for publication, I also need to use superscript in the label. For example: par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1) plot(1:10, ylab=14C-glyphosate line1\n line2) will provide the text in two lines as I would like it. However, I am trying to keep those same line breaks when using expression() to get my superscript number. This will not work, as it aligns the 14C section with the bottom line of the expression making little sense to the reader. par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1) plot(1:10, ylab=expression( ^14*C*-glyphosate line1\n line2)) Is there a way to align the 14C portion of the expression with the top line of the string rather than the bottom line? Any suggestions are greatly appreciated. Andrew -- Andrew Kniss Assistant Research Scientist University of Wyoming Department of Plant Sciences [EMAIL PROTECTED] Office: (307) 766-3949 Fax:(307) 766-5549 __ 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] expression() - Superscript in y-axis, keeping line break in string
On Fri, 2006-08-04 at 09:47 -0600, Andrew Kniss wrote: I've tried several different ways to accomplish this, but as yet to no avail. My y-axis for a plot has a rather long label, and thus I have been using /n to break it into two lines. However, to make it technically correct for publication, I also need to use superscript in the label. For example: par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1) plot(1:10, ylab=14C-glyphosate line1\n line2) will provide the text in two lines as I would like it. However, I am trying to keep those same line breaks when using expression() to get my superscript number. This will not work, as it aligns the 14C section with the bottom line of the expression making little sense to the reader. par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1) plot(1:10, ylab=expression( ^14*C*-glyphosate line1\n line2)) Is there a way to align the 14C portion of the expression with the top line of the string rather than the bottom line? Any suggestions are greatly appreciated. Andrew plotmath, as has been covered many times previously, does not support multi-line expressions. A note should probably be added to ?plotmath on this. Thus, you need to create each line in the label separately: par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1) plot(1:10, ylab = ) # Now use mtext() to place each line of the y axis label mtext(2, text = expression( ^14*C*-glyphosate line1), line = 3) mtext(2, text = line2, line = 2) See ?mtext for more information. HTH, Marc Schwartz __ 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] expression() - Superscript in y-axis, keeping line break in string
Use atop: plot(1, main = expression(atop( ^14*C*-glyphosate line, line2))) On 8/4/06, Andrew Kniss [EMAIL PROTECTED] wrote: I've tried several different ways to accomplish this, but as yet to no avail. My y-axis for a plot has a rather long label, and thus I have been using /n to break it into two lines. However, to make it technically correct for publication, I also need to use superscript in the label. For example: par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1) plot(1:10, ylab=14C-glyphosate line1\n line2) will provide the text in two lines as I would like it. However, I am trying to keep those same line breaks when using expression() to get my superscript number. This will not work, as it aligns the 14C section with the bottom line of the expression making little sense to the reader. par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1) plot(1:10, ylab=expression( ^14*C*-glyphosate line1\n line2)) Is there a way to align the 14C portion of the expression with the top line of the string rather than the bottom line? Any suggestions are greatly appreciated. Andrew -- Andrew Kniss Assistant Research Scientist University of Wyoming Department of Plant Sciences [EMAIL PROTECTED] Office: (307) 766-3949 Fax:(307) 766-5549 __ 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. __ 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] expression() - Superscript in y-axis, keeping line break in string
Sorry, you wanted a ylab=, not a main=. Try using xyplot in lattice: library(lattice) xyplot(1~1, ylab = expression(atop(phantom(0)^14*C*-glyphosate line, line2))) On 8/4/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: Use atop: plot(1, main = expression(atop( ^14*C*-glyphosate line, line2))) On 8/4/06, Andrew Kniss [EMAIL PROTECTED] wrote: I've tried several different ways to accomplish this, but as yet to no avail. My y-axis for a plot has a rather long label, and thus I have been using /n to break it into two lines. However, to make it technically correct for publication, I also need to use superscript in the label. For example: par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1) plot(1:10, ylab=14C-glyphosate line1\n line2) will provide the text in two lines as I would like it. However, I am trying to keep those same line breaks when using expression() to get my superscript number. This will not work, as it aligns the 14C section with the bottom line of the expression making little sense to the reader. par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1) plot(1:10, ylab=expression( ^14*C*-glyphosate line1\n line2)) Is there a way to align the 14C portion of the expression with the top line of the string rather than the bottom line? Any suggestions are greatly appreciated. Andrew -- Andrew Kniss Assistant Research Scientist University of Wyoming Department of Plant Sciences [EMAIL PROTECTED] Office: (307) 766-3949 Fax:(307) 766-5549 __ 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. __ 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] expression() - Superscript in y-axis, keeping line break in string
Actually Gabor, using your solution with 'atop', which I had not considered, it will work with base graphics: par(oma = c(0, 0, 2, 0), mar = c(5, 6, 0.25, 2), lheight = 1) plot(1:10, ylab = expression(atop( ^14*C*-glyphosate line1, line2))) HTH, Marc On Fri, 2006-08-04 at 12:09 -0400, Gabor Grothendieck wrote: Sorry, you wanted a ylab=, not a main=. Try using xyplot in lattice: library(lattice) xyplot(1~1, ylab = expression(atop(phantom(0)^14*C*-glyphosate line, line2))) On 8/4/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: Use atop: plot(1, main = expression(atop( ^14*C*-glyphosate line, line2))) On 8/4/06, Andrew Kniss [EMAIL PROTECTED] wrote: I've tried several different ways to accomplish this, but as yet to no avail. My y-axis for a plot has a rather long label, and thus I have been using /n to break it into two lines. However, to make it technically correct for publication, I also need to use superscript in the label. For example: par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1) plot(1:10, ylab=14C-glyphosate line1\n line2) will provide the text in two lines as I would like it. However, I am trying to keep those same line breaks when using expression() to get my superscript number. This will not work, as it aligns the 14C section with the bottom line of the expression making little sense to the reader. par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1) plot(1:10, ylab=expression( ^14*C*-glyphosate line1\n line2)) Is there a way to align the 14C portion of the expression with the top line of the string rather than the bottom line? Any suggestions are greatly appreciated. Andrew __ 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] expression() - Superscript in y-axis, keeping line break in string
On Fri, 4 Aug 2006, Marc Schwartz (via MN) wrote: On Fri, 2006-08-04 at 09:47 -0600, Andrew Kniss wrote: I've tried several different ways to accomplish this, but as yet to no avail. My y-axis for a plot has a rather long label, and thus I have been using /n to break it into two lines. However, to make it technically correct for publication, I also need to use superscript in the label. For example: par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1) plot(1:10, ylab=14C-glyphosate line1\n line2) will provide the text in two lines as I would like it. However, I am trying to keep those same line breaks when using expression() to get my superscript number. This will not work, as it aligns the 14C section with the bottom line of the expression making little sense to the reader. par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1) plot(1:10, ylab=expression( ^14*C*-glyphosate line1\n line2)) Is there a way to align the 14C portion of the expression with the top line of the string rather than the bottom line? Any suggestions are greatly appreciated. Andrew plotmath, as has been covered many times previously, does not support multi-line expressions. A note should probably be added to ?plotmath on this. I've added a note. I think what is exact is that control chars are not interpreted ('expresssion' is an overloaded work in this context). Thanks for the nudge (and please do continue to make such remarks). Brian Thus, you need to create each line in the label separately: par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1) plot(1:10, ylab = ) # Now use mtext() to place each line of the y axis label mtext(2, text = expression( ^14*C*-glyphosate line1), line = 3) mtext(2, text = line2, line = 2) See ?mtext for more information. HTH, Marc Schwartz __ 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. -- Brian D. Ripley, [EMAIL PROTECTED] 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, UKFax: +44 1865 272595 __ 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] expression() - Superscript in y-axis, keeping line break in string
On Fri, 2006-08-04 at 19:44 +0100, Prof Brian Ripley wrote: On Fri, 4 Aug 2006, Marc Schwartz (via MN) wrote: On Fri, 2006-08-04 at 09:47 -0600, Andrew Kniss wrote: I've tried several different ways to accomplish this, but as yet to no avail. My y-axis for a plot has a rather long label, and thus I have been using /n to break it into two lines. However, to make it technically correct for publication, I also need to use superscript in the label. For example: par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1) plot(1:10, ylab=14C-glyphosate line1\n line2) will provide the text in two lines as I would like it. However, I am trying to keep those same line breaks when using expression() to get my superscript number. This will not work, as it aligns the 14C section with the bottom line of the expression making little sense to the reader. par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1) plot(1:10, ylab=expression( ^14*C*-glyphosate line1\n line2)) Is there a way to align the 14C portion of the expression with the top line of the string rather than the bottom line? Any suggestions are greatly appreciated. Andrew plotmath, as has been covered many times previously, does not support multi-line expressions. A note should probably be added to ?plotmath on this. I've added a note. I think what is exact is that control chars are not interpreted ('expresssion' is an overloaded work in this context). Thanks for the nudge (and please do continue to make such remarks). Brian snip Happy to help and thanks for both noticing and taking the time to incorporate the update. Best regards, Marc __ 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.