![]() Plot.subtitle = element_text(hjust=0.5, size=12), Tag ="My first tag line\nSecond tag line") my.plot<- ggplot(my.df, aes(my.teams, quantity, fill = my.factor)) ![]() By removing the xlim part, I was able to get what I wanted. I am assuming it was because the xlim code was throwing off my plot, given that my x-variable was not numeric. That gave me the second image in my original question above-the one without bars, but with random lines. On the suggestion of Mr.Flick, I had initially tried using the answer found here. Subtitle="of a facet barplot in ggplot") įacet_nested(~top.nest bottom.nest, scales="free_x", space="free") įor completion, here is my final code. ![]() Labs(title = "Successfully added text/annotation below the legend", Here's the full code, and the successful plot! my.plot<- ggplot(my.df, aes(my.teams, quantity, fill = my.factor)) It kind of makes sense given that the x-variable was not (as I earlier mentioned) numeric. It works with a ylim=c(), or just remove all limits. Mine is not.ĮDIT: Okay, the code now works with the added 3 lines, as long as I remove the xlim=c() part. My hunch is that is has to do with the fact that in the example provided in the first response to this question, the x variable is numeric. Whether I add it before, or after, the facet_nested command, the result is the same (see image below). I added these three lines to the original code. I've tried the following suggestion, which doesn't work for me. Scale_y_continuous(expand = c(0, 0), limits=c(0,250)) įacet_nested(~top.nest bottom.nest, scales="free_x", space="free") Plot.subtitle = element_text(hjust=0.5, size=12)) Theme(plot.title = element_text(hjust = 0.5, size=12), Subtitle="of a facet barplot in ggplot?") Labs(title = "How do you add text/annotation either below or above the legend", My.plot<- ggplot(my.df, aes(my.teams, quantity, fill = my.factor)) Library(ggh4x) # for the facet_nested function Those answers don't help because I want the text/annotation to be outside of the plotting area (above/below the legend) and not in the plotting area itself. I've also looked at answers that dealt with creating an annotation on a single facet of a multi-faceted plot. Grid.text worked (I was able to place the text correctly) but I was then unable to use ggsave (which is important) to save the completed plot. I want to place additional text/annotation on the outside of the plot area-above or below the legend-on a geom_bar that has nested facets like below.Īnnotate_custom, and annotate don't work because they add an annotation in every individual facet. I've literally spend a couple of days searching for the correct answer to this.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |