Reputation: 357
I am using the ellipse package, which creates fantastic correlation plots. However, label names are directly taken from column and row names.
This complicates the editing of the labels. I would like to have subscripts in my labels (e.g. k[A1], K[A],..) but I cannot figure out a way how to do it.
Here is my code:
library(ellipse)
library(RColorBrewer)
my_colors <- brewer.pal(5, "RdYlBu")
my_colors=colorRampPalette(my_colors)(100)
Data=rbind(c( 1.00000000, 0.35681412, 0.86504267),
c(0.35681412, 1.00000000, 0.32562542),
c(0.86504267, 0.32562542, 1.00000000))
rownames(Data) = c("kA1", "KA", "kA2")
colnames(Data) = c("kA1", "KA", "kA2")
plotcorr(Data , col=my_colors[Data*50+50] , mar=c(1,1,1,1), cex.axis=1.7, cex.lab=1.8, lwd=4)
Any ideas on how to edit the labels?
Upvotes: 0
Views: 430
Reputation: 118
Maybe someone else has a better answer, but I would suggest using corrplot
instead as it allows plotmath expressions. This gives me:
library(ellipse)
library(RColorBrewer)
library(corrplot)
my_colors <- brewer.pal(5, "RdYlBu")
my_colors=colorRampPalette(my_colors)(100)
Data=rbind(c( 1.00000000, 0.35681412, 0.86504267),
c(0.35681412, 1.00000000, 0.32562542),
c(0.86504267, 0.32562542, 1.00000000))
rownames(Data) = c(":k[A1]", ":K[A]", ":k[A2]")
colnames(Data) = c(":k[A1]", ":K[A]", ":k[A2]")
corrplot(Data , method= "ellipse", col=my_colors[Data*50+50], mar=c(1,1,1,1), cex.axis=1.7, cex.lab=1.8)
Which then looks like this (you can still tweak it a bit to look nicer):
If you are set on using plotcorr
you can probably try some roundabout way using text such as:
text(1:3, 4, expression("k"[A1], "K"[A], "k"[A2]))
text(0, 3:1, expression("k"[A1], "K"[A], "k"[A2]))
Upvotes: 1