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

Allow Pmf instances with non-numeric labels to be used in thinkplot.Hist(). #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cwaldbieser
Copy link

Now you should be able to pass a Pmf instance with string labels to thinkplot.Hist().

@AllenDowney
Copy link
Owner

Thanks for suggesting this.

This feature has been on my to-do list for a while. I just pushed a commit that has a tentative solution: f8f52f2

Would you try it out and see if it works for you? If so, I will add the same feature to thinkplot.Pmf and thinkplot.Pdf.

@cwaldbieser
Copy link
Author

Allen, something seems a bit off. If I try your new code with "The Cookie Problem" from workshop01, I get the histogram plot I expect, but only one label:

cookie = Pmf(['Bowl 1', 'Bowl 2'])
cookie.Print()
thinkplot.Hist(cookie)

The x axis only shows "Bowl 1" between the 2 bars. I believe this is because in Hist() you are using a 0.5 offset in the positions: plt.xticks(xs+0.5, labels). If I change this line to plt.xticks(xs, labels), it works how I'd expect.

@AllenDowney
Copy link
Owner

AllenDowney commented Mar 23, 2017 via email

leblancfg added a commit to leblancfg/BayesMadeSimple that referenced this pull request Apr 24, 2017
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

Successfully merging this pull request may close these issues.

None yet

2 participants