seaborn icon indicating copy to clipboard operation
seaborn copied to clipboard

Needed: mechanism for deriving property values from other properties

Open mwaskom opened this issue 3 years ago • 1 comments

We need a way to specify that a property's values should be (a function of) another property. This is most relevant for assigning the outputs of statistical operations to properties. Tt's become an acute need with the introduction of the Text mark (#3051). It's impossible to annotate statistical results (e.g. to put bar counts above the bars. It's also impossible to assign x/y to the text annotation when using Plot.pair, even without a statistical transform.

I've kicked around a few ideas for this. One would be to make this part of the stat config, e.g. through a method call like

Plot(x).add(so.Text(), so.Hist().assign(text="count"))

But that does not solve the Plot.pair problem.

Another option would be some special within the variable assignment itself, akin to ggplot's after_stat. Plot.add accepts multiple transforms, so this would need to be "after all transforms"; I think it would be too complicated to specify that a variable should be assigned in the middle of the transform pipe.

Will develop this idea further.

mwaskom avatar Oct 03 '22 01:10 mwaskom

Note that it would be nice for this to work in a way that stats could hook into it for their default property definitions so that we get, e.g., a "count" label on the y axis with a Hist stat.

mwaskom avatar Oct 04 '22 00:10 mwaskom