我可以根据数据列中的特定字符串以图形方式更改标记大小吗?

时间:2019-07-17 15:29:59

标签: r plotly r-plotly

我正在为篮球比赛制作动画,希望球标记的尺寸小于球员的标记。在team_id列中,包含三个字符串:team1,team2和ball。有什么办法可以这样改变大小吗?

Plot of the basketball game

# Remove axis lines
ax = list(
  title = "",
  zeroline = FALSE,
  showline = FALSE,
  showticklabels = FALSE,
  showgrid = FALSE
)

# Create the plot
p <- BasketballGame[141522:157640, ] %>%
  plot_ly(
    x = ~Court_Y,
    y = ~Court_X,
    color = ~team_id,
    colors = c('red', 'blue', 'orange'),
    frame = ~time_s,
    text = ~PlayerSensor_ID,
    hoverinfo = "text",
    type = 'scatter',
    mode = 'markers',
    marker = list(size = 20, opacity = 1)
  )%>%
  layout(xaxis = ax, yaxis = ax)%>%
    layout(
    images = list(
        list(
            source = "https://raw.githubusercontent.com/JSommerfeld36/Basketball/master/My_Court.jpg",
            xref = "x",
            yref = "y",
            x = -14500,
            y = 7500,
            sizing = 'stretch',
            sizex = 29000,
            sizey = 15000,
            opacity = 0.8,
            layer = "below"
            )
        )

  )

p

0 个答案:

没有答案