AllenDowney / ThinkStats2

Text and supporting code for Think Stats, 2nd Edition
http://allendowney.github.io/ThinkStats2/
GNU General Public License v3.0
4.02k stars 11.28k forks source link

thinkplot.Show gave error #121

Closed mkepke closed 2 years ago

mkepke commented 5 years ago

I was typing in the commands in chapter 2 and thinkplot.Show(xlabel='value', ylabel='frequency')

gave me the following error

No handles with labels found to put in legend. screen shot 2018-09-28 at 9 33 33 am

AllenDowney commented 5 years ago

That's just a warning, so you can ignore it for now. I will push a fix as soon as I can.

I believe you can avoid it by passing legend=False to Show().

On Fri, Sep 28, 2018 at 9:34 AM, mkepke notifications@github.com wrote:

I was typing in the commands in chapter 2 and thinkplot.Show(xlabel='value', ylabel='frequency')

gave me the following error

No handles with labels found to put in legend. [image: screen shot 2018-09-28 at 9 33 33 am] https://user-images.githubusercontent.com/43621582/46211493-a7a82b80-c301-11e8-8481-7bf3c7765a94.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/AllenDowney/ThinkStats2/issues/121, or mute the thread https://github.com/notifications/unsubscribe-auth/ABy37XCxpKpu_3l_xVznbmC7wJVKompjks5ufiVagaJpZM4W-hDB .

mkepke commented 5 years ago

This is what I get with passing legend=False (same result with legend=false) screen shot 2018-09-28 at 10 45 57 am

mkepke commented 5 years ago

If it helps, I had the same error on Jupyter Notebook chap02ex, but strangely enough the error went away. The error described above occurs on Spyder Python 3.6

AllenDowney commented 5 years ago

Has to be False, not 'False', not false.

On Fri, Sep 28, 2018 at 10:49 AM, mkepke notifications@github.com wrote:

If it helps, I had the same error on Jupyter Notebook chap02ex, but strangely enough the error went away. This occurs on Spyder Python 3.6

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/AllenDowney/ThinkStats2/issues/121#issuecomment-425460272, or mute the thread https://github.com/notifications/unsubscribe-auth/ABy37aSaz-LXMoMafAmf_d5ufGpgaFqZks5ufjbogaJpZM4W-hDB .

mkepke commented 5 years ago

Thanks Allen, that removed the error. Now, to figure out why the data isn't displayed.

nps1984 commented 5 years ago

@mkepke Did you figure out why data isn't displayed? I'm having the same issue.

AllenDowney commented 5 years ago

What development environment are you working in? I strongly recommend Jupyter.

The thinkplot functions you are using are just thin wrappers around matplotlib functions, so I suspect this is a problem with matplotlib in your environment.

nps1984 commented 5 years ago

@AllenDowney I was running in Spyder. I opened up Jupyter to give it a try, but am having the same problem.

The graph is printed without labels on the axes when I do: thinkplot.Hist(hist)

When I do: thinkplot.Show(xlabel='value',ylabel='frequency', legend=False)

A blank graph is printed (but the labels show up :)

nps1984 commented 5 years ago

I just figured it out I believe...

If you run (all in one block): hist = thinkstats2.Hist([1, 2, 2, 3, 5]) thinkplot.Hist(hist) thinkplot.Show(xlabel='value', ylabel='frequency')

It works like a charm.

If you run (all individually): hist = thinkstats2.Hist([1, 2, 2, 3, 5]) # enter

Then: thinkplot.Hist(hist) # enter

Then: thinkplot.Show(xlabel='value', ylabel='frequency') #enter

You get a blank graph with the last statement. Sorry about the confusion.

AllenDowney commented 5 years ago

Glad you worked it out. What development environment are you using?

On Tue, Jan 15, 2019, at 11:32 AM, nps1984 wrote:

I just figured it out I believe...

If you run (all in one block): hist = thinkstats2.Hist([1, 2, 2, 3, 5]) thinkplot.Hist(hist) thinkplot.Show(xlabel='value', ylabel='frequency')

It works like a charm.

If you run (all individually): hist = thinkstats2.Hist([1, 2, 2, 3, 5]) # enter

Then: thinkplot.Hist(hist) # enter

Then: thinkplot.Show(xlabel='value', ylabel='frequency') #enter

Sorry about the confusion.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub[1], or mute the thread[2].

Links:

  1. https://github.com/AllenDowney/ThinkStats2/issues/121#issuecomment-454457665
  2. https://github.com/notifications/unsubscribe-auth/ABy37THuryoT92cHQ0j3VZmuSLjfmNVZks5vDgKkgaJpZM4W-hDB
nps1984 commented 5 years ago

I was using spyder and typing (or copying/pasting) your code into the console. I then switched to JupyterLab, but was essentially doing the same thing. Executing the code from the console and executing line by line. When I would copy/paste chunks of code into the console and execute the entire chunk, it worked! I'm just getting into python so I'm sure it was misunderstanding on my part.

AllenDowney commented 5 years ago

Got it. I will look for places to warn people about this issue.

Thanks!

On Tue, Jan 15, 2019, at 1:08 PM, nps1984 wrote:

I was using spyder and typing (or copying/pasting) your code into the console. I then switched to JupyterLab, but was essentially doing the same thing. Executing the code from the console and executing line by line. When I would copy/paste chunks of code into the console and execute the entire chunk, it worked! I'm just getting into python so I'm sure it was misunderstanding on my part.> — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub[1], or mute the thread[2].

Links:

  1. https://github.com/AllenDowney/ThinkStats2/issues/121#issuecomment-454492391
  2. https://github.com/notifications/unsubscribe-auth/ABy37QewqxbaLo3a74SDwtJQFuxq-cdyks5vDhkMgaJpZM4W-hDB