This is the code that I am having problems with. The bar is moving when changing pitchers(which is good), however it is supposed to be changing color along with it, and it is not doing so.
output$Percentiles <- renderPlot({
MaxVelo <- TM_Percentiles %>%
filter(PitcherTeam == input$Team,
Pitcher == input$Pitcher,
TaggedPitchType %in% c("Fastball", "High", "Low")) %>%
ggplot(TM_Percentiles, mapping = aes(x = MaxVelo_percentile, y = TaggedPitchType, colour = (MaxVelo_percentile))) +
geom_line() +
geom_point(size = 9) +
ggtitle("Max Velo") + xlim(0, 100) + ylim("Fastball") +
xlab("") + ylab("") + theme(
plot.title = element_text(color = "black", size = 15, face = "italic"),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
axis.text.x = element_blank(),
axis.ticks.y = element_blank(),
axis.ticks.x = element_blank(),
axis.text.y = element_text(size = 12, face = "italic", colour = "black")) +
geom_segment(aes(x = 0, xend = 100, y = TaggedPitchType, yend = TaggedPitchType), color = "#9b9b9b", size = 1) +
geom_point(aes(x = 0, y = TaggedPitchType), color = "#9b9b9b", size = 5) +
geom_point(aes(x = 50, y = TaggedPitchType), color = "#9b9b9b", size = 5) +
geom_point(aes(x = 100, y = TaggedPitchType), color = "#9b9b9b", size = 5) +
geom_point(aes(x = MaxVelo_percentile, y = TaggedPitchType, fill = MaxVelo_percentile), pch = 21, color = "black", size = 10) +
geom_text(aes(label = MaxVelo_percentile),hjust = .5, vjust = .4, color = "White",
size = 5) +
theme(legend.position = "none") +
scale_fill_gradient2(midpoint = 50, low = "#cc0000", mid = "black", high = "#2952a3",
na.value = "grey50") +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank())
MaxSpin <- TM_Percentiles %>%
filter(PitcherTeam == input$Team,
Pitcher == input$Pitcher,
TaggedPitchType %in% c("Fastball", "High", "Low")) %>%
ggplot(TM_Percentiles, mapping = aes(x = MaxSpin_percentile, y = TaggedPitchType, colour = (MaxSpin_percentile))) +
geom_line() +
geom_point(size = 9) +
ggtitle("Max Spin") + xlim(0, 100) + ylim("Fastball") +
xlab("") + ylab("") + theme(
plot.title = element_text(color = "black", size = 15, face = "italic"),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
axis.text.x = element_blank(),
axis.ticks.y = element_blank(),
axis.ticks.x = element_blank(),
axis.text.y = element_text(size = 12, face = "italic", colour = "black")) +
geom_segment(aes(x = 0, xend = 100, y = TaggedPitchType, yend = TaggedPitchType), color = "#9b9b9b", size = 1) +
geom_point(aes(x = 0, y = TaggedPitchType), color = "#9b9b9b", size = 5) +
geom_point(aes(x = 50, y = TaggedPitchType), color = "#9b9b9b", size = 5) +
geom_point(aes(x = 100, y = TaggedPitchType), color = "#9b9b9b", size = 5) +
geom_point(aes(x = MaxSpin_percentile, y = TaggedPitchType, fill = MaxSpin_percentile), pch = 21, color = "black", size = 10) +
geom_text(aes(label = MaxSpin_percentile),hjust = .5, vjust = .4, color = "White",
size = 5) +
theme(legend.position = "none") +
scale_fill_gradient2(midpoint = 50, low = "#cc0000", mid = "black", high = "#2952a3") +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank())
ggarrange(MaxVelo, MaxSpin ,nrow = 1, ncol = 2)
})
}
I have tried changing colour = (MaxVelo_percentile) to fill, but that hasn’t changed anything. I think this is something super minor that I need to change in the code. But I can’t figure it out on my own. Please help. Maybe there is a comma in the wrong place?
It’s telling me I need to add more details but I literally dont have anything else to say in regards to the code.