facet_wrap
ggplot
我想看到校准和验证数据,但是有他们自己的
legends
. 下面的代码给了我
plot
我看到的地方
上游、中游和下游
的校准数据
DFplot_1
只有。我希望有相同位置(上游、中游和下游)的验证数据点
DFplot_2
data frame
同样的
figure
传说
过去我见过很多
variables
facet
但不知道怎么做
情节
library(tidyverse)
DF_1 = data.frame(
Models = c("M1", "M2","M3","M4"),
Cost = c(4,44.75,9.28, 6.7),
Upstream = c(0.70,0.80,0.73,0.70),
Midstream = c(0.78,0.82,0.79,0.65),
Downstream = c(0.56,0.85,0.57,0.80),
Type = rep("Calibration", 4)
)
DFPlot_1 = gather(data = DF_1, key = "Variable", value = "Value", -Cost, -Models, -Type)
DF_2 = data.frame(
Models = c("M1", "M2","M3","M4"),
Cost = c(4,44.75,9.28, 6.7),
Upstream = c(0.70,0.80,0.73,0.70),
Midstream = c(0.78,0.82,0.79,0.65),
Downstream = c(0.56,0.85,0.57,0.80),
Type = rep("Validation", 4)
)
DFPlot_2 = gather(data = DF_2, key = "Variable", value = "Value", -Cost, -Models, -Type)
DF = rbind(DFPlot_1, DFPlot_2)
ggplot(data = DF, aes(x = Cost, color = Models, size = Models)) +
geom_point(aes(y = Value)) +
facet_wrap(~ Variable, nrow = 3) +
theme_bw() +
theme(
strip.text.x = element_text(size = 14),
text = element_text(size=20, face = "bold"),
legend.position = c(0.55, 0.85),
legend.direction = "horizontal",
legend.title = element_blank()
) +
labs(x = "\nComputational cost (Hrs)", y = "KGE\n")
这是我从上面的代码中得到的数字
更新:
facet_grid(Type ~ Variable)
相反
小面包
faceting
是否按顺序完成(从D(下游)开始,到U(上游)结束)?有没有办法颠倒顺序?
这是更新后的图