I have a ggplot with a few issues that I'm trying to solve. It's inspired by this post.
My questions:
- I'm showing the top 3 and bottom 3 teams. I want to indicate this somehow on the plot. How do add text on the x-axis which groups them into top 3 and bottom 3?
- The logo for Wolfsburg is partially hidden. How do I make the logos either go at the end of the barchart, or above, so that they are fully visible?
My code:
data <- tibble(
Diff_home_perc = c(-0.3, -0.2, -0.1,-0.05, 0.2, 0.3),
Team = c("A", "B", "C","D", "E", "F"),
ind = c("Green","Green","Green","Red","Red","Red"),
image = list(
image_read_svg("https://www.bundesliga.com/assets/clublogo/DFL-CLU-00000G.svg"),
image_read_svg("https://www.bundesliga.com/assets/clublogo/DFL-CLU-000017.svg"),
image_read_svg("https://www.bundesliga.com/assets/clublogo/DFL-CLU-000018.svg"),
image_read_svg("https://www.bundesliga.com/assets/clublogo/DFL-CLU-000003.svg"),
image_read_svg("https://www.bundesliga.com/assets/clublogo/DFL-CLU-000004.svg"),
image_read_svg("https://www.bundesliga.com/assets/clublogo/DFL-CLU-00000.svg")
)
)
g=ggplot(data, aes(reorder(Team, Diff_home_perc),Diff_home_perc, fill = ind, image = image)) +
ylab("Ratio of points from home games")+ylim(-0.3,0.3)+ylab("Difference")+xlab("Team")+
geom_isotype_col(
img_height = NULL, img_width = grid::unit(0.5, "null"),
ncol = 1, nrow = 1, hjust = 0.5, vjust = 0
) +
guides(fill = "none")+
theme_minimal()+theme(
plot.title = element_blank(),
axis.title.x = element_blank(),
axis.text.x = element_blank(),
text = element_text(size=15),legend.title = element_blank(),legend.position="none")