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

Inconsistent binning when plotting multiple histograms split over a factor #644

Open
jwimberley opened this issue Jun 12, 2018 · 0 comments

Comments

@jwimberley
Copy link

jwimberley commented Jun 12, 2018

Some minimal reproducible code:

import numpy as np
from ggplot import *
import pandas as pd
N = 1000
coin = np.random.binomial(size=N,n=1,p=0.5)
N1 = np.sum(coin)
N0 = np.sum(1-coin)
values = np.zeros(N)
values[coin==0] = np.random.normal(size=N0,loc=0,scale=1)
values[coin==1] = np.random.normal(size=N1,loc=1,scale=2)
categories = map(lambda x: 'A' if x == 0 else 'B', coin)
dat = pd.DataFrame({'Value' : values,
                    'Category' : categories})
ggplot(dat,aes(x='Value',fill='Category')) + geom_histogram(alpha=0.5) + theme_bw()

The produced graph uses different bin schemas for the two histograms however, making comparisons of counts difficult, unlike ggplot2 in R:

image

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

No branches or pull requests

1 participant