subscript in title of plot

3,620 views
Skip to first unread message

Wasteva

unread,
Oct 30, 2012, 8:27:46 PM10/30/12
to ggp...@googlegroups.com
  Can someone please help.
 How do you include a subscript in a plot title by passing it to main or opts( in ggplot2)

Thanks.

Ellen Pape

unread,
Oct 31, 2012, 4:13:03 AM10/31/12
to ggp...@googlegroups.com, steve...@gmail.com
Hi,

Using the expression argument you can create super- and subscripts

Here I inserted a subscript (inserted between "square brackets") in the title of the x axis:

ggplot(...)+...+labs(x=expression(y[2]))

Cheers
Ellen

Ellen Pape (PhD student)

Ghent University
Marine Biology Research Group
Krijgslaan 281, S8
9000 Ghent (Belgium)

Email: Ellen...@Ugent.be
Tel: ++ 32 (0)9 264 85 23
Fax: ++ 32 (0)9 264 85 98

--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

Wasteva

unread,
Oct 31, 2012, 10:45:23 AM10/31/12
to ggp...@googlegroups.com, steve...@gmail.com, ellen...@ugent.be
Thanks, would check if it can be passed to main in normal title plot.
Thanks

Ellen Pape

unread,
Oct 31, 2012, 12:35:37 PM10/31/12
to Wasteva, ggp...@googlegroups.com
Hi Wasteeva,

bu that's similar (labs is for axis label and title is for the plot title):

..+opts(title=expression(title[subscript])


or what do you mean?

Regards

Ellen Pape (PhD student)

Ghent University
Marine Biology Research Group
Krijgslaan 281, S8
9000 Ghent (Belgium)

Email: Ellen...@Ugent.be
Tel: ++ 32 (0)9 264 85 23
Fax: ++ 32 (0)9 264 85 98

Brian Shine

unread,
Oct 31, 2012, 2:35:10 PM10/31/12
to Ellen Pape, Brian Shine, Wasteva, ggp...@googlegroups.com
Try:
x1 <- data.frame(x=1:10,y=(1:10)^2)
ggplot(x1, aes(x,y) ) + labs(x="X values", y = "Y values", title = expression(paste("Some text: ",x^2, "some more text: ",y[3]))) + geom_point()

PastedGraphic-1.pdf
Reply all
Reply to author
Forward
0 new messages