r - How can I edit label text in ggplot2? -


i've built function utilizes ggplot2 create bar chart given style of summary table, there few changes i'd make haven't quite figured out. here's function looks like:

bar_chart_dist <- function(df, x_var, y_var, title) {   title_in_fun <- title   p <- ggplot(df, aes_string(x = df[,x_var], y = df[,y_var])) +    geom_bar(stat = "identity", fill="#005a8c") +    geom_text(aes_string(label= y_var, vjust = -0.2)) +   xlab("") + ylab(y_var) + my_theme() +    ggtitle(title_in_fun) + scale_y_continuous(limits=c(0,100))   return(p) } 

the my_theme function edits font family open sans , changes color grey, among other things.

the data frames using function each 3 variables long -- topic (this name changes each given dataframe), n (number of observations) , percent_of_population (pre-calculated percent of total population in given group). i'm using topic x_var , percent_of_population y_var.

there few things here haven't gotten work:

1) i'd y-axis labeled percent sign (%) , span 0% 100%. i've tried edit scale_y_continuous argument be: scale_y_continuous(labels=percent, limits=c(0,100)) changes scale such upper boundary 10,000%.

2) i'd change font color, size, , family in geom_text argument, add % sign label. family i'd use open sans, doesn't seem recognize that. when set size = 4, legend created, not seem happen in examples i've looked at.

any guys can provide appreciated. i'm not sure what's not working because wrapped in function, , what's not working because it's wrong approach. here's plot looks in current state:


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -