scatterplotmatrix subscript labels
Hi,
I am using the car package in R to complete a scatterplot matrix with linear regression lines. I wish the column names on diagonal to be in subscript for some of the characters, is there a way I can incorporate expression into var labels?
scatterplotMatrix(inbred[1:4],smooth = FALSE,ylim=c(0,0.35), xlim=c(0,0.35), reg.line = lm,diagonal=c("none"),var.labels=colnames(inbred))
I have tried the following
scatterplotMatrix(inbred[1:4],smooth = FALSE,ylim=c(0,0.35), xlim=c(0,0.35), reg.line = lm,diagonal=c("none"),var.labels=colnames(expression(F[123]), expression(F[222]), expression(F[333]), expression(F[444])))
Thanks! :)
• 2,766 views
•
link
1 answer
I once had a lot of fun trying to get an exponent for R^2 in a ggplot geom_point()/geom_smooth() graph.
I can confirm this works for my specific case, but I'm not sure it will work for your needs:
rsquare = paste("R^2 == ", signif(cor$estimate, 3), sep="")
p <- ggplot(data=comb, aes_string(x=gene, y = paste("QS", gene, sep="_"))) +
geom_point() +
geom_smooth(method = "lm", se = FALSE) +
annotate("text", x=max(comb[,gene])-1, y=min(comb[,paste("QS", gene, sep="_")])+0.3, label=rsquare, parse=TRUE, size=4, hjust=0) +
The magic is in the parse=TRUE part of annotate, converting the ^2 to a superscript 2.
EDIT: see that you are talking about "subscript" and not superscript, but possibly similar magic exists...
• 0 views
•
link
Log in to answer this question.
I usually use ggplot so if you would like to use that you can use geom_text() function to label selected points.