r - how to get and modify size legend in ggplot2 -


i having trouble displaying size legend in plot , changing name of size legend.

my data corp has size column either of values 5, 10, 20

i using ggplot2 have legend color

  1. i want add 1 size , manually change size labels..

  2. how increase the font of legend ? it's super tiny (fin, ind util) 15 size shouldnt there want omit , display both legends side side.

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) 

although can't use data yet, can try adding following code:

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")) 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -