我一直在尝试使用python seaborn在同一构面网格中绘制模拟(线)和观察到的(标记),到目前为止没有成功。有什么方法可以使用seaborn重现以下R代码吗?
ps。我知道我可以通过使用plotnine在python上使用ggplot。
干杯!
#--- Sample Simulated Data a
df_sim_a = data.frame(day = seq(1,100),
dat = 2 * seq(1,100) ^ 0.5,
var = "a",
typ = 'sim')
#--- Sample Simulated Data b
df_sim_b = data.frame(day = seq(1,100),
dat = 5 * seq(1,100) ^ 0.8,
var = "b",
typ = 'sim')
#--- Sample Observed Data a
df_obs_a = data.frame(day = seq(1,100, by = 2),
dat = 2 * seq(1,100, by = 2) ^ 0.5 * (rnorm(length(seq(1,100, by = 2)),1,0.1)),
var = "a",
typ = 'obs')
#--- Sample Observed Data b
df_obs_b = data.frame(day = seq(1,100, by = 4),
dat = 5 * seq(1,100, by = 4) ^ 0.8 * (rnorm(length(seq(1,100, by = 4)),1,0.1)),
var = "b",
typ = 'obs')
#--- dataframe with all simulated and observed data
df_plot = rbind(df_sim_a,
df_sim_b,
df_obs_a,
df_obs_b)
#--- Ploting df
library(ggplot2)
ggplot(df_plot, aes(x = day, y = dat)) +
geom_point(data = df_plot[df_plot$typ == 'obs',],aes(x = day, y = dat)) +
geom_line(data = df_plot[df_plot$typ == 'sim',],aes(x = day, y = dat)) +
facet_wrap(.~var)
这就是我要寻找的: Sample Result
请注意,这不是回归。