Barpolar: color bar doesn't match data

I am attempting to make a barpolar plot with three variables: direction (theta), speed (r), and depth (color). If I map to color at the start with the other two variables, a strange grid appears overlaying the plot, and I cannot seem to figure out how to modify the colorbar (such as adding a title). Code:

fig <-
  plot_ly(
    data = Data,
    r = Data$Speed,
    theta = Data$Direction,
    color = Data$Depth,
    colors = 'Greens',
    type = "barpolar",
    marker = list(line = list(
      width = 4,
      colorbar = list(
        title = 'Depth',
        len = 0.6,
        thickness = 25,
        x = 1.1
      )
    ))
  ) %>%
  
  layout(
    title = list(text = "Direction and Speed", y = 4),
    polar = list(
      angularaxis = list(rotation = 90, direction = 'clockwise'),
      radialaxis = list(angle = 90, title = "Speed (µm/s)")
    )
  )

If instead I map to color under marker, I can modify the colorbar, but it has absolutely no connection with the data (different color, different scale). Code:

fig <-
  plot_ly(
    data = Data,
    r = Data$Speed,
    theta = Data$Direction,
    width = 600,
    height = 600,
    type = "barpolar",
    marker = list(
      line = list(
        width = 6,
        color = Data$Depth,
        colorscale = 'Greens'
      ),
      colorbar = list(
        title = 'Depth (ft btc)',
        len = 0.6,
        thickness = 25,
        x = 1.1
      )
    )
  ) %>%
  
  layout(
    title = list(text = "Direction and Speed", y = 0.9),
    polar = list(
      angularaxis = list(rotation = 90, direction = 'clockwise'),
      radialaxis = list(angle = 90, title = "Speed (µm/s)")
    )
  )

I’m sure the solution is quite simple, and I’ve just been looking at this too long to make sense of it. Any help is appreciated. Thanks!

Hey @Matra,

Welcome to the community :partying_face: !

I am not that fluent with R but I will try my best to help you. According to the examples here, you may want to define an overall fig base first, and add each of your variables layer by layer:

For example: This link clearly demonstrates what I try to mean for Python, but you can convert it to R code I assume.

You can also check the documentation page via this link. You may want to ctrl + F: type=‘bar’ for a quick search.

Cheers!