seaborn
seaborn copied to clipboard
Consider Plot.assign method for updating the global spec
This would in principle be redundant with the information that you pass to the constructor. But the utility would be to define a common plot in terms of layer definitions and then to iterate on the variable assignments. Things to consider:
- If
datais to be a valid keyword, maybeupdateis a better name? - Would this method also allow global assignment of "extra" variables, like variables that stat transforms can handle, which are not passable to the constructor?
I was in need of this functionality, and almost opened a new issue.
This would allow to do this:
p = so.Plot(df, x="x", y="y").add(so.Line())
p.update(color="z")
p.update(color="w")
instead of this:
so.Plot(df, x="x", y="y", color="z").add(so.Line())
so.Plot(df, x="x", y="y", color="w").add(so.Line())
right?
Maybe so.Plot() should not take any parameters, and all global mappings should be passed with this method. .global() would be perfect if it weren't a Python keyword. Maybe .globals()?