1

I am seeking assistance in changing the color of the x-axis to white in a Plotly graph that includes two y-axes. In the provided code below, my attempt to conceal the x-axis by setting it to white is not successful. I would appreciate any suggestions on how to achieve this. Thank you!

df <- tibble(x = 1:10, y1= seq(2, 6.5, .5), y2 = seq(4, -5, -1))
fig <- plotly::plot_ly()
fig <- fig %>%
  plotly::add_trace(data = df,
                    x = ~x, 
                    y = ~y1, 
                    type = 'scatter',
                    mode = 'lines',
                    linetype = "solid",
                    name = "y1 axis"
  )
fig <- fig %>%
  plotly::add_trace(data = df,
                    x = ~x, 
                    y = ~y2, 
                    type = 'scatter',
                    mode = 'lines',
                    linetype = "solid",
                    yaxis = "y2",
                    name = "y2 axis"
  )
x <- list(
  title = '',
  zerolinecolor = "#FFFFFF",
  zerolinewidth = 2,
  gridcolor = "#FFFFFF")
y <- list(
  title = '',
  zerolinecolor = '#ffff',
  zerolinewidth = 2,
  gridcolor = "#FFFFFF")
y2 <- list(
  overlaying = "y",
  side = "right")
fig <- fig %>%
  layout(xaxis = x,
         yaxis = y,
         yaxis2 = y2)
fig

I was expecting to format the color of the x-axis when there are two y-axis.

0

1 Answer 1

1
x <- list(
  title = '',
  showline = TRUE,
  showgrid = FALSE,
  zeroline = FALSE)

y1 <- list(
  title = '',
  showline = TRUE,
  showgrid = FALSE,
  zeroline = FALSE)

y2 <- list(
  overlaying = "y",
  side = "right",
  showline = TRUE,
  showgrid = FALSE,
  zeroline = FALSE)

fig <- fig %>%
  layout(yaxis = y1,
         yaxis2 = y2,
         xaxis = x)
fig

Created on 2023-12-06 with reprex v2.0.2

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.