2014-02-06 33 views
2

我有一些麻烦,在我的情节显示尺寸传奇,改变我的尺寸图例的名称。如何获得和修改尺寸传说GGPLOT2

我的数据是总公司已拥有大小列要么是值5,10,20

我使用GGPLOT2我已经有一个传奇的色彩

  1. 我想添加一个适宜的规模和手动更改尺寸标签..

  2. 如何提高传说的字体?这是超级微小(FIN,IND UTIL) 也是15的大小不应该在那里,我想只要忽略它,并排显示两个传说的一面。

enter image description here

p <- ggplot(corp, aes(x=annRisk, y=annRet, color = corp$subsector1, face = "bold")) 

p<- p + geom_point(aes(size = corp$Colsize), alpha = 0.55) 

p<-p + scale_size(range = c(8, 20)) 

p<-p + scale_colour_manual("", values = c("UTIL" = "#fdcc8b", "IND" = "#fc8d59", "FIN" = "#d7301f", 
"ABS" = "#74a9cf", "CMBS" = "#0570b0", "LA" = "#8c96c6", "SOV"= "#88419d", "SUPRA" = "#b3cde3")) 

p<-p+labs(title = "SOME TITLE") 

print(p) 

p<-p+theme(plot.title = element_text(face = "bold", size = 20)) 

p<-p+theme(axis.title.x = element_text(size = 20), axis.text.x = element_text(size = 13)) 
p<-p+theme(axis.title.y = element_text(size = 20), axis.text.y = element_text(size = 13)) 

p<-p+geom_text(aes(label=ifelse(Colsize>=10,subsector2,"")), size=5,color = "black", face = "bold", hjust=-0.1, vjust = 0.1) 


p<-p+scale_x_continuous(labels = percent, name = "Annualized Risk", limits = c(0.05, 0.09)) 

p<-p+scale_y_continuous(labels = percent, name = "Annualized Return", limits = c(0.04, 0.08)) 

p<-p+ theme(legend.position = "bottom") 
print(p) 
+1

我猜你会进一步得到了很多其他人可以实际运行的数据。请[提供最低限度的工作示例(MWE)](http://jaredknowles.com/journal/2013/5/27/writing-a-minimal-working-example-mwe-in-r) –

+0

你是对的。生病发布一些数据与它tomm – qfd

回答

1

虽然我不能用你的数据是,你可以尝试添加以下代码:

p <- p + theme(legend.position = "bottom", 
       legend.title = element_blank(), 
       legend.text = element_text(size=14), 
       legend.box = "horizontal") 

p <- p + scale_size_manual(values=c(5,10,20), labels = c("5","10","20"))