[R] Help needed with ggplot2

bharat rawlley bh@r@t_m_@|| @end|ng |rom y@hoo@co@|n
Sat Aug 21 23:46:59 CEST 2021


Hello, on using the following code for the following data, the graph I get has an x axis where years are mentioned as 2012.5, 2017.5 etc. 

I have the following questions - 
Q1 How can I make the years on x axis as 2011, 2012, 2013, 2014 and so on.. 
Q2 Is there any way to create a small gap between the red and blue bars for aesthetic purposes
Q3 Is there anyway to make the text on top of the bars bolder or thicker? 
Thank you

code - 
ymax <- max(graph_text$percentage)ggplot(aes(x=year, y=percentage, color = gender, fill=gender), data = graph_text)+  geom_bar(position = 'dodge', stat='identity')+  theme_classic()+  geom_text(aes(label = percentage), size = 4, position = position_dodge(width = 1.1), vjust=-0.2) +   scale_y_continuous(limits=c(0, 1.4*ymax))


| 57.14 | 2020 |  male |
| 29.76 | 2020  | female |
| 69.32 | 2019  | male |
| 28.41 | 2019 |  female |
| 57.89 | 2018 |  male |
| 34.21 | 2018  | female |
| 58.59 | 2017 |  male |
| 33.33 | 2017  | female |
| 48.42 | 2016  | male |
| 42.11 | 2016 |  female |
| 59.77 | 2015 |  male |
| 29.89 | 2015 |  female |
| 72.13 | 2014 |  male |
| 18.03 | 2014 |  female |
| 53.33 | 2013 |  male |
| 33.33 | 2013 |  female |
| 55.1 | 2012 |  male |
| 40.82 | 2012  | female |
| 46.55 | 2011  | male |
| 37.93 | 2011  | female |






-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1629581970448blob.jpg
Type: image/png
Size: 42813 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20210821/b2079a33/attachment.png>


More information about the R-help mailing list