[R] ggplot sub- and superscript for axis name
Hi all, For publication purpose, I require to label ggplot figures axes with sub- or superscript text. I tried several ways, but never worked so far, to mix character string, sub- or superscripting on it and even worse, mathematical symbols. Let say I want to write the LateX equivalent of \gamma_{fi} in a ggplot element name, how can I do that? #dumb example foo-data.frame(a=seq(1:100),b=rnorm(100,1,1)) p-ggplot(data=foo,aes(x=a,y=b)) p-p + geom_point() p-p + scale_x_continuous(name='gamma[fi]') print(p) Regards Ben __ R-help@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.
Re: [R] ggplot sub- and superscript for axis name
On Aug 31, 2010, at 9:29 AM, Benoit Boulinguiez wrote: Hi all, For publication purpose, I require to label ggplot figures axes with sub- or superscript text. I tried several ways, but never worked so far, to mix character string, sub- or superscripting on it and even worse, mathematical symbols. Let say I want to write the LateX equivalent of \gamma_{fi} in a ggplot element name, how can I do that? #dumb example foo-data.frame(a=seq(1:100),b=rnorm(100,1,1)) p-ggplot(data=foo,aes(x=a,y=b)) p-p + geom_point() p-p + scale_x_continuous(name='gamma[fi]') Try: p-p + scale_x_continuous(name=expression(gamma[fi])) (I was, however, wondering if you were misspelling phi? But the I don't know any LaTeX.) print(p) -- David Winsemius, MD West Hartford, CT __ R-help@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.
Re: [R] ggplot sub- and superscript for axis name
Hi Ben, Since you already know LaTeX, I would go with what you know. Try p-p + scale_x_continuous(name='$\\gamma_{fi}$') library(tikzDevice) ## may too to install first tikz(file=foo.tex, standAlone=TRUE) print(p) dev.off() system(pdflatex foo.tex) Best, Ista On Tue, Aug 31, 2010 at 1:29 PM, Benoit Boulinguiez benoit.boulingu...@ensc-rennes.fr wrote: Hi all, For publication purpose, I require to label ggplot figures axes with sub- or superscript text. I tried several ways, but never worked so far, to mix character string, sub- or superscripting on it and even worse, mathematical symbols. Let say I want to write the LateX equivalent of \gamma_{fi} in a ggplot element name, how can I do that? #dumb example foo-data.frame(a=seq(1:100),b=rnorm(100,1,1)) p-ggplot(data=foo,aes(x=a,y=b)) p-p + geom_point() p-p + scale_x_continuous(name='gamma[fi]') print(p) Regards Ben __ R-help@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. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org __ R-help@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.