I am trying to build a shiny app that shows NHL shot location data via a contour plot on an image of a hockey rink. I have cleaned that data and was able to successfully build a point plot that marks a point for each shot on goal. But when I try to build a contour plot, the plot becomes layered and choppy (as seen in the image). My code for the plot on my server file is as follows, any idea what I am doing wrong and how I can smooth it out?
ggplot(plot_data, aes(x=xCordall, y=yCordall)) +
background_image(img)+
stat_density_2d(aes(fill= ..level..),geom = 'polygon',alpha= 0.8)+
scale_x_continuous(limits = c(-100, 100))+
scale_y_continuous(limits = c(-42.5, 42.5))+
theme(legend.position = "none")+
theme_void()