Info Viz

Whole League

#change the size of the dot based on points per game metric (dk points/salary)
todateavg %>%
      plot_ly(x=~Avg_Salary, y=~Avg_Pts, color = ~Team,
                hoverinfo = "text",
                text = ~paste("Name:", Name, "<br>",
                              "Avg Points:", Avg_Pts, "<br>",
                              "Avg Salary:", Avg_Salary, "<br>",
                              "Team:", Team)) %>%
        add_markers(size = ~Avg_Ppd) %>%
        layout(xaxis = list(title = "Avg DK Salary", zeroline = FALSE, showgrid=FALSE),
                yaxis = list(title = "Avg DK Points", zeroline = FALSE,  showgrid=FALSE),
               title = "Avg Salary v Avg Points") 

The graphic below represents the Average Salary v Average Points and is colored on Salary/Points ratio. The Dark to Light Spectrum is representing value with lighter being more value per dollar on average.

#Adding color as a factor for Ppd and adding axis titles
todateavg %>%
        plot_ly(x=~Avg_Salary, y=~Avg_Pts, color = ~Avg_Ppd,
                hoverinfo = "text",
                text = ~paste("Name:", Name, "<br>",
                              "Points:", Avg_Salary, "<br>",
                              "Team:", Team)) %>%
        add_markers() %>%
        layout(xaxis = list(title = "DK Salary", zeroline = FALSE, showgrid=FALSE),
                yaxis = list(title = "DK Points", zeroline = FALSE,  showgrid=FALSE),
               title = "Average Salary by Points, Colored by Points per Dollar")

Faceted Chart

The graphic below is broken out by position and Average Points/Average Salary. Clicking on the team icons will add/remove any teams from the chart.

#faceted
todateavg %>%
        group_by(Pos) %>%
                do(p=plot_ly(., x= ~Avg_Salary, y= ~Avg_Pts, color = ~Team, hoverinfo = "text",
                text = ~paste("Name:", Name, "<br>",
                              "Average Points:", Avg_Pts, "<br>",
                              "Average Salary:", Avg_Salary, "<br>",
                              "Team:", Team))) %>%
        subplot(nrows=5, shareY=TRUE, shareX=TRUE)

The chart below is a faceted breakdown of Average DK points versus Opponent. This will display the strengths/weaknesses of each team in regard to position.

#Average DK points Scored against Opponent by Faceted by Position - chart only changes Center for some reason
oppavg %>%
        group_by(Pos) %>%
                do(p=plot_ly(., x= ~Pos, y= ~Avg_Pts_Agst, color = ~Opp, hoverinfo = "text",
                text = ~paste("Average Points Against:", Avg_Pts_Agst, "<br>",
                              "Pos:", Pos, "<br>",
                              "Team:", Opp))) %>%
        subplot(nrows=10, shareY=FALSE, shareX=FALSE)

The chart below represents a stacked view providing some insights into what teams give up to position.

#stacking by team 
oppavg %>%
  plot_ly(x=~Opp, y=~Avg_Pts_Agst, color = ~Pos) %>%
  add_bars() %>%
  layout(barmode = "stack")

Below is a boxplot representing Points against Opponent across all positions.

#Box Plot
todate %>%
  plot_ly(x=~Opp, y=~Pts) %>%
  add_boxplot()

The following boxplot represents Points scored by Position

#Box Plot
todate %>%
  plot_ly(x=~Pos, y=~Pts, color = ~Pos) %>%
  add_boxplot()

Charts by Position

The Charts below are all broken out by position. Size of the token represents value on an Average Points/Average Salary Ratio. Color represents team

center

#by position - center
cplotavg <- center %>%
        plot_ly(
                x = ~Avg_Salary, y = ~Avg_Pts, hoverinfo = "text",
                text = ~paste("Name:", Name, "<br>",
                              "Average Pts:", Avg_Pts, "<br>",
                              "Avg Salary:", Avg_Salary, "<br>",
                              "Team:", Team)) %>%
        add_markers(
                size = ~Avg_Ppd,
                color = ~Team,
                marker = list(opacity = 0.3,
                              sizemode = "diameter",
                              sizeref = 2)) %>%
        layout(xaxis = list(title = "AVG DK Salary", zeroline = FALSE, showgrid=FALSE),
                yaxis = list(title = "AVG DK Points", zeroline = FALSE,  showgrid=FALSE),
               title = "Centers AVG")
cplotavg

DK points allowed to Center

#Opponent Points DK allowed
cplotopp <- oppavg %>%
  filter(Pos == "C") %>%
        plot_ly(
                x = ~Opp, y = ~Avg_Pts_Agst, hoverinfo = "text",
                text = ~paste("Team:", Opp, "<br>",
                              "Average Pts Against:", Avg_Pts_Agst)) %>%
        add_bars(
                color = ~Opp,
                marker = list(opacity = 0.7,
                              sizemode = "diameter",
                              sizeref = 2)) %>%
        layout(xaxis = list(title = "Team", zeroline = FALSE, showgrid=FALSE),
                yaxis = list(title = "AVG DK Points Against", zeroline = FALSE,  showgrid=FALSE),
               title = "Centers AVG")
cplotopp

power forward

#by position - power forward
pfplotavg <- pforward %>%
        plot_ly(
                x = ~Avg_Salary, y = ~Avg_Pts, hoverinfo = "text",
                text = ~paste("Name:", Name, "<br>",
                              "Average Pts:", Avg_Pts, "<br>",
                              "Avg Salary:", Avg_Salary, "<br>",
                              "Team:", Team)) %>%
        add_markers(
                size = ~Avg_Ppd,
                color = ~Team,
                marker = list(opacity = 0.3,
                              sizemode = "diameter",
                              sizeref = 2)) %>%
        layout(xaxis = list(title = "AVG DK Salary", zeroline = FALSE, showgrid=FALSE),
                yaxis = list(title = "AVG DK Points", zeroline = FALSE,  showgrid=FALSE),
               title = "Power Forward AVG")
pfplotavg

DK Points allowed to Power Forward

#Opponent Points DK allowed
pfplotopp <- oppavg %>%
  filter(Pos == "PF") %>%
        plot_ly(
                x = ~Opp, y = ~Avg_Pts_Agst, hoverinfo = "text",
                text = ~paste("Team:", Opp, "<br>",
                              "Average Pts Against:", Avg_Pts_Agst)) %>%
        add_bars(
                color = ~Opp,
                marker = list(opacity = 0.7,
                              sizemode = "diameter",
                              sizeref = 2)) %>%
        layout(xaxis = list(title = "Team", zeroline = FALSE, showgrid=FALSE),
                yaxis = list(title = "AVG DK Points Against", zeroline = FALSE,  showgrid=FALSE),
               title = "Power Forward AVG")
pfplotopp

small forward

#by position - small forward
sfplotavg <- sforward %>%
        plot_ly(
                x = ~Avg_Salary, y = ~Avg_Pts, hoverinfo = "text",
                text = ~paste("Name:", Name, "<br>",
                              "Average Pts:", Avg_Pts, "<br>",
                              "Avg Salary:", Avg_Salary, "<br>",
                              "Team:", Team)) %>%
        add_markers(
                size = ~Avg_Ppd,
                color = ~Team,
                marker = list(opacity = 0.3,
                              sizemode = "diameter",
                              sizeref = 2)) %>%
        layout(xaxis = list(title = "AVG DK Salary", zeroline = FALSE, showgrid=FALSE),
                yaxis = list(title = "AVG DK Points", zeroline = FALSE,  showgrid=FALSE),
               title = "Small Forward AVG")
sfplotavg

DK Points allowed to Small Forward

#Opponent Points DK allowed
Sfplotopp <- oppavg %>%
  filter(Pos == "SF") %>%
        plot_ly(
                x = ~Opp, y = ~Avg_Pts_Agst, hoverinfo = "text",
                text = ~paste("Team:", Opp, "<br>",
                              "Average Pts Against:", Avg_Pts_Agst)) %>%
        add_bars(
                color = ~Opp,
                marker = list(opacity = 0.7,
                              sizemode = "diameter",
                              sizeref = 2)) %>%
        layout(xaxis = list(title = "Team", zeroline = FALSE, showgrid=FALSE),
                yaxis = list(title = "AVG DK Points Against", zeroline = FALSE,  showgrid=FALSE),
               title = "Small Forward AVG")
Sfplotopp

All Forward eligible players

#All Forward eligible players
fplotavg <- forward %>%
        plot_ly(
                x = ~Avg_Salary, y = ~Avg_Pts, hoverinfo = "text",
                text = ~paste("Name:", Name, "<br>",
                              "Average Pts:", Avg_Pts, "<br>",
                              "Avg Salary:", Avg_Salary, "<br>",
                              "Team:", Team)) %>%
        add_markers(
                size = ~Avg_Ppd,
                color = ~Team,
                marker = list(opacity = 0.3,
                              sizemode = "diameter",
                              sizeref = 2)) %>%
        layout(xaxis = list(title = "AVG DK Salary", zeroline = FALSE, showgrid=FALSE),
                yaxis = list(title = "AVG DK Points", zeroline = FALSE,  showgrid=FALSE),
               title = "Forward AVG")
fplotavg

shooting guard

#by position - shooting guard
sgplotavg <- sguard %>%
        plot_ly(
                x = ~Avg_Salary, y = ~Avg_Pts, hoverinfo = "text",
                text = ~paste("Name:", Name, "<br>",
                              "Average Pts:", Avg_Pts, "<br>",
                              "Avg Salary:", Avg_Salary, "<br>",
                              "Team:", Team)) %>%
        add_markers(
                size = ~Avg_Ppd,
                color = ~Team,
                marker = list(opacity = 0.3,
                              sizemode = "diameter",
                              sizeref = 2)) %>%
        layout(xaxis = list(title = "AVG DK Salary", zeroline = FALSE, showgrid=FALSE),
                yaxis = list(title = "AVG DK Points", zeroline = FALSE,  showgrid=FALSE),
               title = "Shooting Guard AVG")
sgplotavg

DK Points Allowed to Shooting Guard

#Opponent Points DK allowed
sgplotopp <- oppavg %>%
  filter(Pos == "SG") %>%
        plot_ly(
                x = ~Opp, y = ~Avg_Pts_Agst, hoverinfo = "text",
                text = ~paste("Team:", Opp, "<br>",
                              "Average Pts Against:", Avg_Pts_Agst)) %>%
        add_bars(
                color = ~Opp,
                marker = list(opacity = 0.7,
                              sizemode = "diameter",
                              sizeref = 2)) %>%
        layout(xaxis = list(title = "Team", zeroline = FALSE, showgrid=FALSE),
                yaxis = list(title = "AVG DK Points Against", zeroline = FALSE,  showgrid=FALSE),
               title = "Shooting Guard AVG")
sgplotopp

Point guard

#by position - Point guard
pgplotavg <- pguard %>%
        plot_ly(
                x = ~Avg_Salary, y = ~Avg_Pts, hoverinfo = "text",
                text = ~paste("Name:", Name, "<br>",
                              "Average Pts:", Avg_Pts, "<br>",
                              "Avg Salary:", Avg_Salary, "<br>",
                              "Team:", Team)) %>%
        add_markers(
                size = ~Avg_Ppd,
                color = ~Team,
                marker = list(opacity = 0.3,
                              sizemode = "diameter",
                              sizeref = 2)) %>%
        layout(xaxis = list(title = "AVG DK Salary", zeroline = FALSE, showgrid=FALSE),
                yaxis = list(title = "AVG DK Points", zeroline = FALSE,  showgrid=FALSE),
               title = "Point Guard AVG")
pgplotavg

DK Points Allowed to Point Guard

#Opponent Points DK allowed
pgplotopp <- oppavg %>%
  filter(Pos == "PG") %>%
        plot_ly(
                x = ~Opp, y = ~Avg_Pts_Agst, hoverinfo = "text",
                text = ~paste("Team:", Opp, "<br>",
                              "Average Pts Against:", Avg_Pts_Agst)) %>%
        add_bars(
                color = ~Opp,
                marker = list(opacity = 0.7,
                              sizemode = "diameter",
                              sizeref = 2)) %>%
        layout(xaxis = list(title = "Team", zeroline = FALSE, showgrid=FALSE),
                yaxis = list(title = "AVG DK Points Against", zeroline = FALSE,  showgrid=FALSE),
               title = "Point Guard AVG")
pgplotopp

All guard eligible players

#all guard eligible players
gplotavg <- guard %>%
        plot_ly(
                x = ~Avg_Salary, y = ~Avg_Pts, hoverinfo = "text",
                text = ~paste("Name:", Name, "<br>",
                              "Average Pts:", Avg_Pts, "<br>",
                              "Avg Salary:", Avg_Salary, "<br>",
                              "Team:", Team)) %>%
        add_markers(
                size = ~Avg_Ppd,
                color = ~Team,
                marker = list(opacity = 0.3,
                              sizemode = "diameter",
                              sizeref = 2)) %>%
        layout(xaxis = list(title = "AVG DK Salary", zeroline = FALSE, showgrid=FALSE),
                yaxis = list(title = "AVG DK Points", zeroline = FALSE,  showgrid=FALSE),
               title = "Guard AVG")
gplotavg