2014-02-06 36 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"))