]> git.donarmstrong.com Git - neurodebian.git/blobdiff - survey/makestats
RF: fixed order in 1 figure and deprecated need to import mvpa
[neurodebian.git] / survey / makestats
index a15b5f7dca214304306e0a7385098508dc7d81f5..3fc697a91401586ef80a25980b64d99568dc2791 100755 (executable)
@@ -1,6 +1,5 @@
 #!/usr/bin/python
 
-from mvpa.misc.plot.base import plot_bars
 from glob import glob
 try:
     from json import load as jload
@@ -44,7 +43,7 @@ resource_categories = {
     'pypi': 'PyPi',
     'pythonbundles': 'Python bundles',
     'sourceforge': 'Sourceforge',
-    'other': 'Other resource'
+    'otherres': 'Other resource'
     }
 # software categories
 sw_categories = {
@@ -57,7 +56,7 @@ sw_categories = {
         'bci': 'Brain-computer interface',
         'acq': 'Hardware interface/Data acquisition',
         'rt': 'Real-time solutions',
-        'psychophys': 'Psychophysics/Experiment control'
+        'psychphys': 'Psychophysics/Experiment control'
         }
 
 # some meaningful groups of OSes
@@ -65,7 +64,7 @@ redhat_family = ["rhel", "centos", "fedora", "scilinux"]
 debian_family = ["debian", "ubuntu", "biolinux"]
 suse_family = ["suse", "slel"]
 other_linux_family = ["gentoo", "mandriva", "arch", "slackware", "otherlinux"]
-other_family = ["starbsd", "unix", "qnx", "beos", "solaris", "other"]
+other_family = ["starbsd", "unix", "qnx", "beos", "solaris", "other", "dontknow"]
 
 os_cat_names = {
         'win': 'Windows',
@@ -213,9 +212,10 @@ def mkpic_os_per_env(db, destdir):
         pl.barh(x, stat, left=bottoms, color=os_colors[i],
                label=db.get_nice_name(os), height=0.8)
         bottoms += stat
-    pl.legend(loc='lower left')
+    pl.legend(loc='center left')
     pl.yticks(x + 0.4,  env_names[::-1])
     pl.ylim(-0.25, len(envs))
+    pl.xlim(0,1)
     pl.title("Operating system preference by environment")
     pl.xlabel("Fraction of submissions")
     pl.subplots_adjust(left=0.15, right=0.97)
@@ -238,12 +238,12 @@ def mkpic_time_per_env(db, destdir):
     x = np.arange(len(envs))
     bottoms = np.zeros(len(envs))
     for i, t in enumerate(time_order):
-        stat = [env_stats[e][t] for e in envs]
+        stat = [env_stats[e][t] for e in envs[::-1]]
         pl.barh(x, stat, left=bottoms, color=time_colors[i],
                label=db.get_nice_name(t), height=.6)
         bottoms += stat
-    pl.legend(loc='center left')
-    pl.yticks(x + 0.2,  env_names)
+    pl.legend(loc='lower left')
+    pl.yticks(x + 0.2,  env_names[::-1])
     pl.ylim(-0.4, len(envs))
     pl.title("Research activity time by environment")
     pl.xlabel("Fraction of submissions")
@@ -255,7 +255,8 @@ def mkpic_submissions_per_key(db, destdir, key, title, sortby='name',
                             multiple=False):
     counts = db.get_counts(key)
     pl.figure(figsize=(6.4, (len(counts)-2) * 0.4 + 2))
-    tmargin = .8/len(counts)
+    if not len(counts): tmargin = 0.4
+    else: tmargin = .8/len(counts)
     if tmargin > 0.3: tmargin = 0.3
     pl.subplots_adjust(left=0.03, right=0.97, top=1-tmargin, bottom=tmargin)
     pl.title(title)
@@ -276,7 +277,7 @@ def mkpic_submissions_per_key(db, destdir, key, title, sortby='name',
         pl.yticks(x + 0.5,  ['' for s in stats])
         text_offset = pl.gca().get_xlim()[1] / 30.
         for i, s in enumerate(stats[::-1]):
-            pl.text(text_offset, i+.5, db.get_nice_name(s[0]),
+            pl.text(text_offset, i+.5, db.get_nice_name(s[0]) + " [%d]" % (s[1],),
                     horizontalalignment='left',
                     verticalalignment='center',
                     bbox=dict(facecolor='white', alpha=0.8, edgecolor='white'))
@@ -293,9 +294,11 @@ def mkpic_software(db, destdir):
         mkpic_submissions_per_key(
             db, destdir, 'sw_%s' % typ,
             title="Software popularity: %s" % db.get_nice_name(typ),
-            sortby='name')
+            sortby='count')
 
 def mkpic_rating_by_os(db, env, items, destdir, title):
+    from mvpa.misc.plot.base import plot_bars
+
     pl.figure(figsize=(6.4, 4.8))
     for i, os in enumerate(os_order):
         ratings = [db.select_match(env,
@@ -405,12 +408,12 @@ def main(srcdir, destdir):
         os.makedirs(destdir)
 
     mkpic_submissions_per_key(
-        db, destdir, 'virt_prod', sortby='name',
-        title='Virtualization product popularity\n(multiple choices per submission possible)')
+        db, destdir, 'virt_prod', sortby='count',
+        title='Virtualization product popularity')
 
     mkpic_submissions_per_key(
         db, destdir, 'bg_datamod', sortby='count',
-        title='Submissions per data modality\n(multiple choices per submission possible)')
+        title='Submissions per data modality')
 
     mkpic_submissions_per_key(
         db, destdir, 'bg_position', title='Submissions per position', sortby='count')
@@ -430,7 +433,7 @@ def main(srcdir, destdir):
                        "Personal environment", "I prefer this particular scientific software environment because ...")
     mkpic_rating_by_os_hor_joined(db, 'man_os', ['man_r%i' % i for i in range(1, 5)], destdir,
                        "Managed environment")
-    mkpic_rating_by_os_hor_joined(db, 'virt_host_os', ['man_r%i' % i for i in range(1, 4)], destdir,
+    mkpic_rating_by_os_hor_joined(db, 'virt_host_os', ['virt_r%i' % i for i in range(1, 4)], destdir,
                        "Virtual environment (by host OS)")
 
     # submission stats: this is RST