I have the following data.frame with which i want to make a ggplot:
> topmicegrn
Topic Antigen n tc
0 BCP 0.350533878 25193
0 HEL 0.344341682 25193
0 OVA 0.194974795 25193
0 RSV 0.110149645 25193
1 BCP 0.453020134 298
1 HEL 0.228187919 298
1 OVA 0.318791946 298
10 BCP 0.979310345 145
10 OVA 0.013793103 145
10 HEL 0.006896552 145
...
The plot looks like this atm:
ggplot(topmicegrn, aes(Topic, n, label=tc)) +
geom_bar(stat = "identity", aes(fill = Antigen)) +
geom_text(stat='identity', position = 'stack') +
scale_fill_brewer(palette="YlGnBu") +
coord_flip()
Now, i would like to keep only the 'tc'-label at the end of each bar (so one label per 'Topic'), and get rid of the ones on every stack. I tried with geom_text(aes(group=Topic))
, but it results in the same plot as shown.
Also, not every 'Topic' contains every 'Antigen', and the ordering is quite messy(the 'Topic' column is a factor which i ordered in a specific order), so using these solutions does not work for me. Any ideas?