且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将绘图条形图和箱线图放在线迹前面

更新时间:2023-02-07 15:59:10

也许这可以帮助您开始.您没有提供数据集,所以这里是一个小的虚构示例.您可以使用布局向图形添加形状(在您的案例中为一条线).如您所见,该条位于线上方.希望能帮到你!

Maybe this could help you started. You did not provide a data set so here is a small made-up example. You can use layout to add a shape (a line in your case) to your graphic. As you can see the bar is above the line. Hope it helps!

plot_ly() %>% 
add_bars(x = c("giraffes", "orangutans", "monkeys"), y = c(20, 14, 23)) %>% 
layout(shapes = list(list(type = "lines",x0 = -1, x1 = 3, xref = "x", y0 = 3, y1 = 3, yref = "y", layer = "below")))