Question: scatterplotmatrix subscript labels
0
gravatar for dp0b
20 months ago by
dp0b30
dp0b30 wrote:

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

scatterplot car R • 808 views
ADD COMMENTlink modified 20 months ago by WouterDeCoster32k • written 20 months ago by dp0b30

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

ADD REPLYlink written 20 months ago by Sej Modha3.6k
1
gravatar for WouterDeCoster
20 months ago by
Belgium
WouterDeCoster32k wrote:

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 COMMENTlink modified 20 months ago • written 20 months ago by WouterDeCoster32k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 565 users visited in the last hour