Skip to content

stat_bin2d cuts values #604

Closed
Closed

Description

@Hoeze

Hi, I'd like to create a 2d bin plot of this dataset:
grafik

But as soon as I try to plot it:

plot = (
    pn.ggplot(df, pn.aes(x="score", y="residuals"))
    + pn.stat_bin_2d(binwidth=0.1)
)
plot

I just see this output:
grafik

However, I know that there should be points at score == 0:

plot = (
    pn.ggplot(df, pn.aes(x="score", y="residuals"))
    + pn.geom_point()
)
plot

grafik

What is the issue here?

Activity

  1. Hoeze commented on Jul 8, 2022

    @Hoeze
    Author

    Here is the dataset:
    test.csv.gz

    I am using plotnine v0.9.0

  2. Hoeze commented on Jul 11, 2022

    @Hoeze
    Author

    Hi @has2k1, is there something we can do about?
    This is a really critical bug as it creates misleading results.

  3. has2k1 commented on Jul 13, 2022

    @has2k1
    Owner

    Minimal Reprex

    import pandas as pd
    import numpy as np
    from plotnine import *
    
    n = 100
    np.random.seed(123)
    df = pd.DataFrame({
        'x': np.random.randint(0, 2, n),  # Issue is the 0
        'y': np.random.randn(n)
    })
    
    (ggplot(df, aes('x', 'y'))
     + stat_bin_2d(binwidth=0.1)
    )

    stat_bin_2d

  4. Hoeze commented on Aug 16, 2022

    @Hoeze
    Author

    @has2k1 I'm sorry for bothering you, but is there any solution to this issue yet?

  5. has2k1 commented on Aug 17, 2022

    @has2k1
    Owner

    I have a solution, I just wasn't satisfied with it. I will give it another look before the next couple of days and just publish it regardless.

  6. added a commit that references this issue on Sep 1, 2022
    1d559e5
  7. Hoeze commented on Sep 15, 2022

    @Hoeze
    Author

    @has2k1 Thanks for fixing this bug.
    Would you mind also releasing a new plotnine version having the bug fix?

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions