0

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()

Choppy Contour Plot

  • If your version of `ggplot2` is below 3.3, consider upgrading, there were some significant improvements to address that specific problem. See https://www.tidyverse.org/blog/2020/03/ggplot2-3-3-0/#better-contour-calculations – r2evans Jul 05 '20 at 18:33
  • 1
    Updating my ggplot2 had no effect unfortunately – Mufasa Jones Jul 05 '20 at 19:13

0 Answers0