i never have trouble editing the legend with ggplot, but with geom_text I seem to be having some trouble.
i <- ggplot(threedusg, aes(x=DxRAPM, y=X3PAr, label=threedusg$Player)) i + geom_text(aes(size=threedusg$CS3,hjust=0,vjust=0)) + scale_x_continuous(limits=c(0,6))
Here is what my legend looks http://imgur.com/H6vZN2b
The size of the text comes from data with percentages. I would prefer to have the text in the legend read as actual percentages. For instance it says .30 instead of 30%. Any help would be greatly appreciated!
Using the scales
library (which you will need to explicitly load), you can use the percent
labeller. (Note you shouldn't be referencing the columns of a data set using $
within a ggplot call.
library(scales)
ggplot(threedusg, aes(x = DxRAPM, y = X3PAr, label = Player)) +
geom_text(aes(size = CS3), hjust = 0, vjust = 0) +
scale_x_continuous(limits = c(0,6)) +
scale_size(label = percent)
On a reproducible example
foo <- data.frame(x=1:5,y=1:5,player=letters[1:5],rate = c(0.2,0.5,0.7,0.1,0.8))
ggplot(foo, aes(x=x,y=y,label=player)) +
geom_text(aes(size=rate)) +
scale_size(label = percent)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.