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

Scale has no effect for Pair plots in next-gen interface #2910

Closed
eringrant opened this issue Jul 17, 2022 · 3 comments · Fixed by #3458
Closed

Scale has no effect for Pair plots in next-gen interface #2910

eringrant opened this issue Jul 17, 2022 · 3 comments · Fixed by #3458

Comments

@eringrant
Copy link

eringrant commented Jul 17, 2022

The objects interface looks great, in particular the ability to have combination pair and facet plots. However, I ran into a bug when attempting to log-scale an axis for a paired plot with seaborn==0.12.0b2.

Expected behavior (no log-scaling where none applied):

import seaborn as sns
import seaborn.objects as so
diamonds = sns.load_dataset("diamonds")

(
    so.Plot(
        diamonds, 
        x="carat", 
    )
    .pair(y=(
        "price", 
        "price", 
    ))
    .add(so.Scatter())
)

image

Unexpected behavior (no log-scaling even when calling scale(y="log")):

import seaborn as sns
import seaborn.objects as so
diamonds = sns.load_dataset("diamonds")

(
    so.Plot(
        diamonds, 
        x="carat", 
    )
    .pair(y=(
        "price", 
        "price", 
    ))
    .scale(y="log")
    .add(so.Scatter())
)

image

Expected behavior (log-scaling works without pairing):

import seaborn as sns
import seaborn.objects as so
diamonds = sns.load_dataset("diamonds")

(
    so.Plot(
        diamonds, 
        x="carat", 
        y="price"
    )
    .scale(y="log")
    .add(so.Scatter())
)

image

@mwaskom
Copy link
Owner

mwaskom commented Jul 17, 2022

Hi @eringrant thank you so much for testing out the beta!

This might not be documented (yet), but individual variables in a paired plot can be scaled (and otherwise modified in Plot.limit, Plot.label, etc.) with {var}{idx}, i.e.:

(
    so.Plot(
        diamonds, 
        x="carat", 
    )
    .pair(y=(
        "price", 
        "price", 
    ))
    .add(so.Scatter())
    .scale(y1="log")
)

image

Then there's a separate question of "if there are multiple y axes, should doing .scale(y="log") set a log scale on all of them?" I could imagine that being useful! Is that what you were expecting here?

@eringrant
Copy link
Author

Thanks, @mwaskom—being able to independently scale the y-axes by indexing them in this way is great. I didn't see that in the documentation, but perhaps I missed it.

Yes, I'd expect .scale(y="log") to scale all the axes! (And for that to be incompatible with scaling them independently as y1="log", etc.)

@beyarkay
Copy link
Contributor

Chiming in to say I got confused by this behaviour as well, but the solution (y1="log") works well for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants