I want to create a segment/point plot that has the topBatter on the Y axis and the topTen Distance on the Y axis. When I create it the plot reverses the X and Y.
I'm a bit stuck as to why this one isn't working.
Thanks for any guidance. I appreciate this community.
#Top HR by Distance
topTenDistance <- c(485, 502, 484, 492, 489, 499, 500, 497, 489, 501)
topBatter <- c("Ba", "Ca", "Da", "Fa", "Ga", "Ha", "Ja", "Ka", "Ya", "Ja")
topCombined <- cbind(topBatter, topTenDistance)
topCombined <- as.data.frame(topCombined)
topCombined %>%
ggplot(aes(x=topTenDistance, y=topBatter)) +
geom_segment( aes(xend=topTenDistance, yend=0)) +
geom_point( size=1.5, color="#134A8E") +
scale_y_discrete() +
coord_flip() +
ggtitle("Top HRs by Distance") +
labs(subtitle = "MLB 2022 Season") +
xlab("Player's Name") +
ylab("Distance (in ft")