绘图时间多个来自不同tibles的序列
I have three different tibble data fram as below and I want to combine them into one graph, is there anyone can help me?
how do I combine them into one plot?
I look forward to hear from you.
best, Michael
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编辑:
请参阅Flick先生关于制定可再现例子的评论。另外,请参见Stackoverflow的问一个好问题。目前,尚不清楚您想做的事情是否对数据有任何意义。对于绘制多个时间序列的一般任务(在同一日期范围内),您可以参考以下答案。
在单独的数据帧(tibbles)中绘制多个时间序列,
您需要使用
dplyr :: bind_cols
函数将tibbles组合到较大的数据帧中。然后,您可以使用ggplot为每个时间序列添加图层或行。
但是,我建议使用
tidyr
将数据转换为长格式,以获得最大的GGPLOT。我做了一个基本 peprex 您的情况下。
img src =“ https://i.sstatic.net/kwyvn.png”
alt =“”> < >由
Edit:
See Mr. Flick's comment about formulating a reproducible example. Also, see stackoverflow's Asking a good question. Right now, it's not clear if what you want to do makes any sense for your data. For the general task of plotting multiple time series (over the same date range), you can refer to the answer below.
Plotting multiple time series in separate data frames (tibbles)
You'll want to combine the tibbles into a larger one using the
dplyr::bind_cols
function.Then you can use ggplot to add layers, or lines, for each time series.
But I'd recommend transforming your data to a long format using
tidyr
to get the most out ggplot.I made a basic reprex of your scenario below.
Created on 2022-04-15 by the reprex package (v2.0.1)