This is probably extremely simple but I cannot seem to find the answer. I am adding greek lettering to my legend (mu). However, when I do this the black outline around my legend key boxes does not appear when I use legend.key = element_rect(colour = "black")
. I also want the legend key text to be bold but this also doesn't work.
Anyone got any tips?
Here is an example:
Example data (sorry, not sure how to upload it so imported from .csv):
Name,Time,Dose,Variable,n,Mean,SD,Median,Upper.SEM,Lower.SEM
Ted,1,0,P,3,20.1341,1.049791,20,0.5728394,0.5569923
Fred,1,0,P,3,38.63702,1.042969,37.74,0.9499892,0.9271918
Ted,1,1,P,3,22.79528,1.110182,21.64,1.4179833,1.334943
Fred,1,1,P,3,24.25966,1.156925,23.82,2.1300073,1.9580866
Example code:
R<- subset(example, Dose=="0")
S<- subset(example, Dose=="1")
R_S<- rbind(R,S)
names(R_S)
w<- ggplot(R_S, aes(x=Name, y=Mean,fill=interaction(Name,Dose) ))
w<-w + geom_bar(stat="identity", position="dodge")
w<-w + geom_errorbar(aes(ymax=Mean+Upper.SEM, ymin=Mean-Lower.SEM), position=position_dodge(0.9), width=0.5)
w<- w+ scale_fill_manual(values=c("#00FF00","#FF0000","#98FB98","#FF7F50"),name="",labels=c(~"Fred- Control (0"* mu * M* ") ", ~"Ted- Control (0"* mu * M* ") ",~"Fred- Treated (1"* mu * M* ") ",~"Ted- Treated (1"* mu * M* ") "))
w + theme(legend.key = element_rect(colour = "black"))
w<-w+ theme(legend.position = "bottom")
w<-w+ theme(legend.key.size = unit(1.5, "lines"))
w<- w + theme(legend.text = element_text(colour="black", size = 18, face = "bold"))
w<-w+ theme(axis.title.x = element_text( face="bold",size=20))
w<-w+ theme(axis.title.y = element_text(face="bold",size=20))
w<-w+ theme(axis.text.x=element_text(face="bold",colour='black', size=18))
w<-w+ theme(axis.text.y=element_text(face="bold",colour='black', size=16))
w