1
votes

I'm using plotly to make a scatter polar plot in r to plot site aspect against wind speed.

Is there a way to change the axis so 0 degrees is still at the top, but 90 degrees is at the 3 o'clock position on the axis? and I'd also like to add the compass direction lables (N,E,S,W) to the plot

This is the code I've used and the plot I've made so far:

library(plotly)

plot_ly(type='scatterpolar',r=dat$y,theta=dat$x,mode='markers')

plot

1

1 Answers

0
votes

You can use angularaxis in the plotly layout to indicate angular direction (clockwise), initial rotation, and add tick text letters for labels.

dat <- data.frame(
  x=sample(1000),
  y=sample(1000)
)

library(magrittr)
library(plotly)

plot_ly(type='scatterpolar',r=dat$y,theta=dat$x,mode='markers') %>%
  layout(
    polar = list(
      angularaxis = list(
        rotation = 90,
        direction = 'clockwise',
        tickvals = seq(0,359,90),
        ticktext = c("N", "E", "S", "W")
      )
    )
  )

Plot

scatterpolar plot example