我正在尝试使用两个不同的分组条形图Y axis
来衡量两个不同的列。这是数据:
SUCURSAL EXISTENCIA COSTO_MEDIO
0 MELENARA 0.128 643.2
1 LAS TORRES 1.872 659.2
2 GALDAR 0.304 659.2
3 SEBADAL 0.851 623.8
4 ARINAGA 0.176 620.4
5 LANZAROTE 0.232 686.4
6 FUERTEVENTURA 0.480 680.2
这是我的代码:
ay <- list(
tickfont = list(color = "red"),
overlaying = "y1",
side = "right"
)
p <- plot_ly(dfplot, x = dfplot$SUCURSAL, y = dfplot$EXISTENCIA, type = "bar", opacity = 0.4, name = 'EXISTENCIA', yaxis = "y1") %>%
add_trace(x = dfplot$SUCURSAL, y = dfplot$COSTO_MEDIO, type = "bar", name = 'COSTO', yaxis = "y2") %>%
layout( xaxis = list(title = ""), yaxis = list(title = "", tickfont= list(size = 10, color = "black"), showticklabels = TRUE), yaxis2= ay, barmode = 'group' ) %>%
config(displayModeBar = F)
p
我遇到的问题是两组条形图重叠。我不可能看到它被组合在一起,彼此放在一边。如何用两组条形表示它?
任何想法?