Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize internal scaling operation #3440

Merged
merged 6 commits into from
Aug 20, 2023
Merged

Generalize internal scaling operation #3440

merged 6 commits into from
Aug 20, 2023

Conversation

mwaskom
Copy link
Owner

@mwaskom mwaskom commented Aug 20, 2023

This PR updates most sns functions to use the transforms set on a pre-existing matplotlib axes such that statistics are computed in the visualized space. Previously, support for transformed axes was a little spotty, at most supporting log scales (but not similar scales, like symlog).

f, axs = plt.subplots(1, 4, figsize=(6, 3), sharey=True, layout="constrained")
plots = [sns.lineplot, sns.pointplot, sns.boxplot, sns.violinplot]
for ax, func in zip(axs.flat, funcs):
    ax.set_yscale("symlog")
    plot(diamonds, x="color", y="price", ax=ax)

image

This also fixes #3352, a bug introduced in the v0.13 dev series when jumping the gun on this functionality.

Arbitrary scales are also now handled properly on the orient axis of categorical plots:

f, ax = plt.subplots()
ax.set_xscale("symlog")
sns.boxplot(tips, x=10 ** tips["size"], y="total_bill", hue="sex", native_scale=True)

image

The code is fairly messy but, alas, that's rather unavoidable given the architecture underlying the function interface and was a major motivator for the development of the objects interface (and corresponding rearchitecting).

@codecov
Copy link

codecov bot commented Aug 20, 2023

Codecov Report

Merging #3440 (44d4418) into master (2386036) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3440   +/-   ##
=======================================
  Coverage   98.32%   98.33%           
=======================================
  Files          77       77           
  Lines       24305    24335   +30     
=======================================
+ Hits        23899    23929   +30     
  Misses        406      406           
Files Changed Coverage Δ
seaborn/_base.py 97.66% <100.00%> (+0.11%) ⬆️
seaborn/categorical.py 98.90% <100.00%> (-0.01%) ⬇️
seaborn/distributions.py 96.23% <100.00%> (-0.12%) ⬇️
seaborn/relational.py 99.69% <100.00%> (+<0.01%) ⬆️
tests/test_base.py 99.69% <100.00%> (+<0.01%) ⬆️
tests/test_categorical.py 99.13% <100.00%> (+<0.01%) ⬆️

@mwaskom mwaskom merged commit af613f1 into master Aug 20, 2023
12 checks passed
@mwaskom mwaskom deleted the enh/scaling branch August 20, 2023 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Categorical scatter plots on symlog-scaled axis
1 participant