AllenDowney / ThinkDSP

Think DSP: Digital Signal Processing in Python, by Allen B. Downey.
https://allendowney.github.io/ThinkDSP/
3.93k stars 3.2k forks source link

"No handles with labels found to put in legend" issue #60

Closed esunlon closed 5 years ago

esunlon commented 5 years ago

Hi all i just read the chapter 1 and ready to code a little bit. after cloned the repo, i run a few codes and python give me this words:No handles with labels found to put in legend. i googled something, but no results. here is my codes, my running env is anaconda 3.5.2 issue :


from __future__ import print_function, division

# %matplotlib inline
import thinkdsp
import thinkplot

import numpy as np

cos_sig = thinkdsp.CosSignal(freq=440, amp=10, offset=0)
sin_sig = thinkdsp.SinSignal(freq=880, amp=0.5, offset=0)

cos_sig.plot()
thinkplot.config(xlabel='Time (s)', ylabel='amp(p)')
KVISDAOWNER commented 5 years ago

I have the same issue

kvnloughead commented 5 years ago

Same. A good reason to learn the underlying matplotlib interface, and not just the thinkplot wrapper.

nickk commented 5 years ago

Shouldn't the config line be before the plot line? i.e.: thinkplot.config(xlabel='Time (s)', ylabel='amp(p)') cos_sig.plot()

If I run your code I don't get an error but my graph has no legend labels. Switching the lines around fixes that.

AllenDowney commented 5 years ago

Think should be resolved now with a newer version of thinkplot.py

But let me know if it is not.

sachinmotwani20 commented 4 years ago

The issue isn't resolved yet. Screenshot at 2020-03-26 18-10-08

quoit1 commented 4 years ago

I am using spyder 4.0.1 and having the same issue. Not getting axes, legends, labels or titles even though I am declaring it in the code. Thanks.

AllenDowney commented 4 years ago

Sounds like there are two issues:

  1. Still getting a warning if there are no labels. Ok, I am working on changes now that will get rid of thinkplot.py altogether, and this problem should go with it.

  2. Figures don't show up right in spyder. I'm not sure what the problem is, but I don't recommend using spyder for Jupyter notebooks.

SatyamGaba commented 4 years ago

I face this same issue with "matplotlib". It turned out that my plot axis was getting cleared before I was putting the legends. If "thinkplot" is based on "matplotlib" it might help the developer in debugging