[R] Help needed with ggplot2

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Sat Aug 21 23:56:54 CEST 2021


See ?dput for how to provide a reproducible example (a reprex). Or see here:
https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

It will improve your chance of getting a helpful and quick response.

Cheers,
Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Sat, Aug 21, 2021 at 2:47 PM bharat rawlley via R-help
<r-help using r-project.org> wrote:
>
>
> 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 |
>
>
>
>
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list