scatterplotmatrix subscript labels
1
0
Entering edit mode
7.9 years ago
dp0b ▴ 80

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! :)

car R scatterplot • 2.3k views
ADD COMMENT
0
Entering edit mode

I usually use ggplot so if you would like to use that you can use geom_text() function to label selected points.

ADD REPLY
1
Entering edit mode
7.8 years ago

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...

ADD COMMENT

Login before adding your answer.

Traffic: 1766 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6