简体   繁体   English

如何将条形图放在顶层

[英]How can I put plotly bar chart on the top layer

I am trying to put a bar chart on the top of other charts using Plotly in R, but couldn't get it shown corrected.我试图在 R 中使用 Plotly 将条形图放在其他图表的顶部,但无法正确显示。 Any help would be appreciated.任何帮助,将不胜感激。 Thanks!谢谢!

  library(plotly)
dat1 <- data.frame(
  date = as.Date(c("2020-03-26", "2020-03-27", "2020-03-28", "2020-03-29","2020-03-30", "2020-03-31", "2020-04-01")),
  value = c(1,3,5,7,5,3,1),
  box = c(1,2,rep(4,5))
)

fig <- plot_ly(data = dat1, x = ~ date, y = ~ box, mode = "line+markers", type='scatter', stackgroup = 'one', fillcolor='#d8f4ef' )
fig <- fig %>% add_bars(data = dat1, x= ~date, y = ~ value, inherit = F)
fig

maybe you can use add_trace() to make it也许你可以使用add_trace()来制作它

you can find example here你可以在这里找到例子

hope it helps希望能帮助到你

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何更改水平 Plotly 条形图中轨迹的顺序? - How can I change the order of traces in horizontal Plotly bar chart? 如何在带有颜色变量的R Plotly条形图中保留所需的顺序 - How can I retain desired order in R Plotly bar chart with color variable 如何使用 R Plotly 在后台将组和堆栈条形图与 layout.shape 结合起来? - How can I combine group and stack bar chart with layout.shape in background using R Plotly? 如何使用 R 制作前 3 个情节堆叠的条形图? - How can I make a top 3 plotly stacked bar graph using R? 在R中使用绘图表时如何完全删除顶部top声栏或部分? - How to remove completely top hower bar or partial while using plotly chart in R? 如何使用 R plotly 在条形图中的条形末端(而不是居中)放置刻度线和轴标签(或刻度文本)? - How can I position tickmarks and axis labels (or ticktext) at the end of bars (rather than centered) in a bar chart using R plotly? 如何使用Plotly的条形图防止x值相同的条形相互重叠 - How can I prevent bars with the same x value from overlapping each other using Plotly's Bar Chart Plotly:如何自定义堆叠条形图中的颜色? - Plotly: How to customize colors in a stacked bar chart? 当 plotly 条形图 textposition = “inside” 时,如何移动条形内部的文本? - When plotly bar chart textposition = “inside”, how do I shift the text inside the bar? 情节酒吧和折线图 - plotly bar and line chart
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM