mwaskom / seaborn

Statistical data visualization in Python
https://seaborn.pydata.org
BSD 3-Clause "New" or "Revised" License
12.45k stars 1.92k forks source link

FIX: Enable str transformations to Color/Interval scales #3688

Open MaozGelbart opened 5 months ago

MaozGelbart commented 5 months ago

Prior to this PR, strings such as "log", "sqrt", etc. (.scale "magic args") are invalid inputs to Color/Interval variables' scales (#2869). It is possible to define a Continuous(trans="log") scale and achieve continuous transformation functionality to these properties. So the following lines are equivalent but the former is currently erroneous:

so.Plot(tips, "total_bill", "tip", color="total_bill").add(so.Dots()).scale(color="log")
so.Plot(tips, "total_bill", "tip", color="total_bill").add(so.Dots()).scale(color=so.Continuous(trans="log"))

This PR adds str transformations support directly to Color/Interval properties. It is resolved after property-specific arguments (i.e. .scale(color="log") will look for "log" colormap first and will apply "log" transformation only if there's no "log" colormap registered).

Fixes #2869 .