简体   繁体   English

如何在R + Plotly + Shiny中绘制两个X轴

[英]How to plot two X axes in R + Plotly + Shiny

I have three columns, Depth , Flow In , and Flow Out . 我有三列, 深度流入流出 I want to plot Flow In and Flow out against Depth . 我想绘制流入和 流出来反对深度 I want Depth to be on the Y axis whereas x1 to be Flow In and x2 to be Flow Out . 我希望深度在Y轴上,而x1是流入 ,x2是流出

You may need to melt the dataframe using melt() from the reshape2 package. 您可能需要使用reshape2包中的melt()来熔化数据框。 This would allow you to display the values side by side. 这将允许您并排显示值。 You could use something like the following: 您可以使用如下所示的内容:

df.p <- ggplot(df, aes(x, value, fill = variable))
  df.p + 
    geom_bar(stat="identity",position="dodge") 
  })

Another thought, having no background on what your data is, you may consider a waterfall chart if you want to show depth as something always below the x-axis. 还有一种想法,由于没有数据背景,如果您想将深度显示为始终在x轴以下,则可以考虑使用瀑布图。 You can use geom_rect for this. 您可以为此使用geom_rect。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM