I have a dataset that is a list of arrays. Each array is a 30s trial, and within each array is a list of times of events that occurred in the trial over 30s. So for example, one array would be [0.2, 3., 5., 6.2,.....29.99].
I want to plot only the events that occurred in the first 10s of each trial using eventplot. This is what I have tried:
plt.eventplot(test_spikes[test_spikes<10]);
But I get the error "'<' not supported between instances of 'list' and 'int'"
I'm not sure what I'm doing wrong. Thank you for your help in advance!
Try
[d for d in data if d < 10]
As you have a list of (what I assume are) numpy
arrays, you need to perform your comparison for each array individually. The error message is trying to tell you this; the outer list is not a numpy array and therefore does not support comparison with an integer.
to_plot = [x[x<10] for x in test_spikes]
For this to work, x must be np.array
s. If that is not given, you can convert them as such:
test_spikes = [np.array(x) for x in test_spikes]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.