Software (ソフト)‎ > ‎Saplab‎ > ‎

Saplab script example

#coding:utf-8
#!/usr/bin/env python
# histall.py
# by Kazutoshi Sasahara
# 2009.05.11

import saplab, pylab

# Parameters
table = "syll_g6_1_clustered"
field = "duration"
bins = 20
xrange = (20, 200)
ages = [48, 64, 86, 128]

# Make objects for saplab and sapdat
sap = saplab.Saplab()
bird = sap.setTable(table)

# Make histograms
for i in range(len(ages)):
    durations = sap.getdat(bird, field, "age=" + str(ages[i]))
    pylab.subplot(2, 2, i + 1)
    pylab.hist(durations, bins, xrange)
    pylab.title("P" + str(ages[i]))
   
# plot all histograms at once
pylab.show()


Result



Comments