BayesMadeSimple
BayesMadeSimple copied to clipboard
Allow `Pmf` instances with non-numeric labels to be used in `thinkplot.Hist()`.
Now you should be able to pass a Pmf instance with string labels to thinkplot.Hist().
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: f8f52f2043a13c76c0a5abfeb3c80da63374b449
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.
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.
Thanks for letting me know. I'll investigate as soon as I can.
On Wed, Mar 22, 2017 at 9:42 PM, Carl [email protected] wrote:
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.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/AllenDowney/BayesMadeSimple/pull/2#issuecomment-288592308, or mute the thread https://github.com/notifications/unsubscribe-auth/ABy37buk7rA0u5XIledNHcb7_fGR1hqIks5roc3ygaJpZM4Mhnt1 .