plotly graph with 2 y axes to represent angle

Hi everybody,

I would like to represent angle (took by a vessel) on a graph, wich is not really clear with an axe from 0 to 360 (to be at 10° is equal to be at 350° for a skipper).
So I want to represent my values with 2 axes : one form 360 to 180 (for the values from 180 to 360), the second one from 0 to 180 (the values from 0 to 180). Thus if the skipper is at 10 or 350° it would be equivalent...

I have started a plotly visualisation, but I don't manage to modify my first axe y to display it from 360 to 180 (and not the opposite). I tryed the yaxis arguments but It doesn't work...

Thank you if you have an idea :slight_smile:

library(plotly)
library(dplyr)

jour <- c("25/03/21","25/03/21","25/03/21","25/03/21","25/03/21")
heure <- c("01:03:52","02:03:52","03:03:52","04:03:52","05:03:52")
degre <- c(120,160,30,200,290)

df <- data.frame(jour,heure,degre)

df$degre_T <- df$degre
df$degre_B <- df$degre

df$degre_T[df$degre_T < 180] <- NA
df$degre_B[df$degre_B >= 180] <- NA

plot_ly(df, x = ~heure, y = ~degre_T, type = "scatter", name = "angle") %>%
add_markers(x = ~heure, y = ~degre_B, mode = "scatter", yaxis = "y2", name = "angle") %>%
layout(yaxis2 = list(overlaying = "y", side = "right")
# yaxis = list(
# autotick = FALSE,
# ticks = "outside",
# tick0 = 360,
# dtick = 10,
# ticklen = 180,
# tickwidth = 2,
# tickcolor = toRGB("blue")
# )
)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.