This graph is generated with the following code:
library(tidyverse)
library(plotly)
df <- data.frame(
DEP = c("ABC", "DEF", "GHI")
, VALUE = c(100, 110, 120)
, LINE = c(-0.1, 0.7, 0.9)
)
xAxis <- list(
title = ""
, tickangle = 0
, tickfont = list(size = 10)
)
yAxis <- list(
side = "left"
, showgrid = TRUE
, zeroline = TRUE
, title = ""
)
yAxis2 <- list(
side = "right"
, autotick = FALSE
, ticks = "outside"
, tick0 = 0
, dtick = 0.1
, showgrid = TRUE
, zeroline = TRUE
, overlaying = "y"
)
plot_ly(data = df, x = ~DEP) %>%
add_trace(data = df, x = ~DEP, y = ~VALUE, name = 'VALUE', type = "bar", yaxis = "y", textposition = "auto") %>%
add_trace(data = df, x = ~DEP, y = ~LINE, name = 'LINE', mode = "lines", type = "scatter",
line = list(width = 4), yaxis = "y2") %>%
layout(
margin = list(r=50, b = 150)
, xaxis = xAxis
, yaxis = yAxis
, yaxis2 = yAxis2
, showlegend = FALSE
)
I would like to change the graph so that the zeroline of the left y axis is shifted to the zeroline of the right y axis. Consequently the bars should be shifted too:


