question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

stat_bin2d cuts values

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
has2k1commented, Jul 13, 2022

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

0reactions
Hoezecommented, Sep 15, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

stat_bin2d/ set lower bound for number of objects in bin for ...
In my code because I wish to count objects in certain geographic locations. I do not want to display bins on my plot...
Read more >
stat_bin2d with drop=FALSE still drops some 0-count cells
The drop parameter in stat_bin2d does not appear to work as advertised: docs state that "if [drop is] TRUE removes all cells with...
Read more >
stat_bin2d with geom_point (or, stat_sum with binning)
I have a data set containing approximately 1.2 million points. They are TCP payload sizes, so 'x' takes integer values from 1 to...
Read more >
Heatmap of 2d bin counts — geom_bin_2d • ggplot2
Divides the plane into rectangles, counts the number of cases in each rectangle, and then (by default) maps the number of cases to...
Read more >
scale_fill_binned throws error if all bins have the same value
I want to print a couple of ggplots in a group_walk loop. But one of the plots only returns values in one bin...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found