r - editing the legend on geom_text() -
i never have trouble editing legend ggplot, geom_text seem having trouble.
<- ggplot(threedusg, aes(x=dxrapm, y=x3par, label=threedusg$player)) + geom_text(aes(size=threedusg$cs3,hjust=0,vjust=0)) + scale_x_continuous(limits=c(0,6))
here legend looks http://imgur.com/h6vzn2b
the size of text comes data percentages. prefer have text in legend read actual percentages. instance says .30 instead of 30%. appreciated!
using scales
library (which need explicitly load), can use percent
labeller. (note shouldn't referencing columns of data set using $
within 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 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)
Comments
Post a Comment