Ticket #20 (closed defect: fixed)
Cannot easily plot AnalogSignal
| Reported by: | jnowacki | Owned by: | somebody |
|---|---|---|---|
| Priority: | major | Milestone: | 0.2 |
| Component: | core | Keywords: | |
| Cc: |
Description (last modified by apdavison) (diff)
The bug I've found was that I cannot plot easily analogue signals. Namely, if array provided to matplotlib is 1d (ndim = 1), then it tries to change it into a column vector. It does that by using newaxis. Let say that we have vector v, which v.shape = (n,), then to get column vector we do vc = v[:,newaxis], which is, in fact equivalent to vc = v[:,None]. Both numpy and quantities sorts this out well, but not neo's BaseAnalogSignal. It doesn't know how to handle None correctly and throws an exception, namely, that method i.start does not exist. I've attached a patch that solves it for me. I'm not sure it is the most elegant way, but when v[:,None] is called, the i in __getitem__(i) is a tuple, usually i = (slice(None, None, None), None). I went around it and delegate the job back to quantities, which works as I've checked. If you have other ways of dealing with that, please feel free to change it, but it has to be addressed in my opinion. A workaround without modifying the code is to cast BaseAnalogSignal to numpy array and then plot it.

