Plotly R:在Tableau这样的酒吧图中创建分隔线
我有此数据框架:
df = data.frame(
Period = c("FY2015", "FY2015", "FY2015", "FY2015", "FY2015", "FY2015", "FY2016", "FY2016",
"FY2016", "FY2016", "FY2016", "FY2016"),
Region = c("Africa", "Asia", "Australia", "Europe", "North America", "South America",
"Africa", "Asia", "Australia", "Europe", "North America", "South America"),
Revenue = c(1.0e+07, 2.0e+07, 7.0e+07, 1.2e+08, 1.5e+08, 6.0e+07, 8.0e+06, 1.6e+07, 5.6e+07,
9.6e+07, 1.2e+08, 4.8e+07))
我想在区域中拥有一个
plotly
bar绘图,就像我做过在Tableau中。
这里有提示吗?
I have this dataframe:
df = data.frame(
Period = c("FY2015", "FY2015", "FY2015", "FY2015", "FY2015", "FY2015", "FY2016", "FY2016",
"FY2016", "FY2016", "FY2016", "FY2016"),
Region = c("Africa", "Asia", "Australia", "Europe", "North America", "South America",
"Africa", "Asia", "Australia", "Europe", "North America", "South America"),
Revenue = c(1.0e+07, 2.0e+07, 7.0e+07, 1.2e+08, 1.5e+08, 6.0e+07, 8.0e+06, 1.6e+07, 5.6e+07,
9.6e+07, 1.2e+08, 4.8e+07))
I would like to have a plotly
bar plot in divided by Region
, just like I did here in Tableau.
Any tips here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道一种完全自动的方式,但是我们可以通过制作刻面,去除它们之间的填充并在边界上添加垂直线来伪造它。
在这种情况下,GGPLOT以两个离散类别(“ FY2015”和“ FY2016”),将它们视为1和2的值。默认条形宽度和填充意味着这些面板的边缘在右侧为0.4右边为2.6。
I don't know a totally automatic way, but we can fake it by making facets, removing the padding between them, and adding vertical lines at the borders.
In this case, with two discrete categories ("FY2015" and "FY2016"), ggplot treats them under the hood as values of 1 and 2. The default bar width and padding means that the edges of these panels are at 0.4 on the right and 2.6 on the right.