如何随着时间的推移绘制比较的直方图?
我需要长时间观察两种处理(WW和WS)下的叶子区域,所以我想随着时间的推移绘制直方图比较图表,但是我不知道如何将两个处理的两个栏放在一个中图形。
数据如下:
cd<-structure(list(Pos_heliaphen = c("Y12", "Y13", "Y20", "Y21",
"Y34", "Y35", "Y42", "Y43", "Z06", "Z07", "Z22", "Z23", "Z36",
"Z37", "Z44", "Z45", "Y12", "Y13", "Y20", "Y21", "Y34", "Y35",
"Y42", "Y43", "Z06", "Z07", "Z22", "Z23", "Z36", "Z37", "Z44",
"Z45"), traitement = c("WW", "WS", "WS", "WW", "WS", "WW", "WS",
"WW", "WW", "WS", "WS", "WW", "WS", "WW", "WW", "WS", "WW", "WS",
"WS", "WW", "WS", "WW", "WS", "WW", "WW", "WS", "WS", "WW", "WS",
"WW", "WW", "WS"), Variete = c("Angelica", "Angelica", "Angelica",
"Angelica", "Angelica", "Angelica", "Angelica", "Angelica", "Angelica",
"Angelica", "Angelica", "Angelica", "Angelica", "Angelica", "Angelica",
"Angelica", "Angelica", "Angelica", "Angelica", "Angelica", "Angelica",
"Angelica", "Angelica", "Angelica", "Angelica", "Angelica", "Angelica",
"Angelica", "Angelica", "Angelica", "Angelica", "Angelica"),
Date_obs = structure(c(19135, 19135, 19135, 19135, 19135,
19135, 19135, 19135, 19135, 19135, 19135, 19135, 19135, 19135,
19135, 19135, 19145, 19145, 19145, 19145, 19145, 19145, 19145,
19145, 19145, 19145, 19145, 19145, 19145, 19145, 19145, 19145
), class = "Date"), SF_Plante_Totale = c(0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67589.64, 71868.33, 69883.2,
73892.79, 72106.38, 82228.68, 73393.92, 63867.78, 70127.46,
64710.27, 76991.58, 75486.69, 80237.34, 74250.9, 68804.73,
63714.6)), row.names = c(NA, -32L), class = c("tbl_df", "tbl",
"data.frame"))
我使用的代码如下(有冗余操作,因为我的原始数据具有更多的“ VELIETE”):
df<-subset(cd, Variete %in% c("Angelica"))
options(scipen=200)
df$Date_obs <- as.Date(df$Date_obs)
df %>%
select(1,2,3,4,5) %>%
pivot_longer(starts_with("SF")) %>%
ggplot(aes(Date_obs, value,group=Pos_heliaphen)) +
geom_bar(stat = "identity",fill="steelblue") +
scale_x_date(date_labels = "%Y-%m-%d")+
facet_wrap(~Pos_heliaphen,drop=TRUE)+
labs(y=expression(paste('Original total leaf area (mm'^2,')')))+
theme(legend.position="bottom", axis.text.x = element_text(angle = 90, hjust = 1), axis.title.x = element_blank())
我得到了以下数字:
net/5mz5b.jpg“ rel =“ nofollow noreferrer 两个条形在一个图中圆圈(一个是WW,另一个是WS)。 像下面的图。然后只剩下8个图。
因为现在只是观察的开始,所以我们实际上没有时间表。但是下面的两个数字来自去年。我只是不知道如何将同一天的WS和WW放在一个数字中。
I need to observe the leaf area under the two treatments (WW and WS) for a long time, so I want to draw a histogram comparison chart over time, but I don't know how to put the two bars of two treatments in one graph.
The data is as follows:
cd<-structure(list(Pos_heliaphen = c("Y12", "Y13", "Y20", "Y21",
"Y34", "Y35", "Y42", "Y43", "Z06", "Z07", "Z22", "Z23", "Z36",
"Z37", "Z44", "Z45", "Y12", "Y13", "Y20", "Y21", "Y34", "Y35",
"Y42", "Y43", "Z06", "Z07", "Z22", "Z23", "Z36", "Z37", "Z44",
"Z45"), traitement = c("WW", "WS", "WS", "WW", "WS", "WW", "WS",
"WW", "WW", "WS", "WS", "WW", "WS", "WW", "WW", "WS", "WW", "WS",
"WS", "WW", "WS", "WW", "WS", "WW", "WW", "WS", "WS", "WW", "WS",
"WW", "WW", "WS"), Variete = c("Angelica", "Angelica", "Angelica",
"Angelica", "Angelica", "Angelica", "Angelica", "Angelica", "Angelica",
"Angelica", "Angelica", "Angelica", "Angelica", "Angelica", "Angelica",
"Angelica", "Angelica", "Angelica", "Angelica", "Angelica", "Angelica",
"Angelica", "Angelica", "Angelica", "Angelica", "Angelica", "Angelica",
"Angelica", "Angelica", "Angelica", "Angelica", "Angelica"),
Date_obs = structure(c(19135, 19135, 19135, 19135, 19135,
19135, 19135, 19135, 19135, 19135, 19135, 19135, 19135, 19135,
19135, 19135, 19145, 19145, 19145, 19145, 19145, 19145, 19145,
19145, 19145, 19145, 19145, 19145, 19145, 19145, 19145, 19145
), class = "Date"), SF_Plante_Totale = c(0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67589.64, 71868.33, 69883.2,
73892.79, 72106.38, 82228.68, 73393.92, 63867.78, 70127.46,
64710.27, 76991.58, 75486.69, 80237.34, 74250.9, 68804.73,
63714.6)), row.names = c(NA, -32L), class = c("tbl_df", "tbl",
"data.frame"))
The code I used is as follows (There are redundant operations because my original data has more "variete"):
df<-subset(cd, Variete %in% c("Angelica"))
options(scipen=200)
df$Date_obs <- as.Date(df$Date_obs)
df %>%
select(1,2,3,4,5) %>%
pivot_longer(starts_with("SF")) %>%
ggplot(aes(Date_obs, value,group=Pos_heliaphen)) +
geom_bar(stat = "identity",fill="steelblue") +
scale_x_date(date_labels = "%Y-%m-%d")+
facet_wrap(~Pos_heliaphen,drop=TRUE)+
labs(y=expression(paste('Original total leaf area (mm'^2,')')))+
theme(legend.position="bottom", axis.text.x = element_text(angle = 90, hjust = 1), axis.title.x = element_blank())
And I got the figure as below:
But I want to compare the two bars circled together in one graph (One is WW, the other is WS).
Like this graph below. Then only 8 graphs left in the end.
Because right now is just the beginning of observation, so we don't really have time line. But the two figures below are from last year. I just don't know How to put the WS and WW of the same day in one figure.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定这就是您想要的,但是
new
添加
I'm not sure this is what you wanted but
New
add