Is it possible to access facetted data?
Apologies for asking a question via an issue. Let me know if there's a more appropriate route you'd prefer.
I'm trying to create a facetted plot using facet_wrap that includes a geom_polygon that renders a shaded confidence interval around a fitted model. As is, to achieve this I would need to be able to access the facet filtered data to generate the polygon dataframe and I can't see a way to do this. I suspect that I'm either missing something obvious or I've ended up down a dead-end and need to rethink my approach entirely. Any guidance would be appreciated.
Psuedo-code illustration:
p = (
p9.ggplot(
melted_df,
p9.aes(
x="x",
y="y",
),
)
+ p9.facet_wrap('variable', scales='free', ncol=2)
+ p9.geom_point()
##confidence interval polygon
+ p9.geom_polygon(
data=get_ci_df( ***would want to pass facet data in here*** ),
mapping=p9.aes(x="x", y="ci", size="0.6"),
fill="grey",
alpha=0.3,
)
)
I think you want to have your own stat, i.e stat_my_ci! Look at a simple stat like stat_qq. Implement your ci logic in the compute_group method and return a dataframe with the right columns.
Aha! I took some wrong turns (I've never really used stats with ggplot so I wasn't clear on how the mapping is meant to be specified across the geom and stat) but I have it working now.
Thanks for the pointer on this problem and the library overall.