- pl.title('Submissions per data modality')
- pl.bar(x, [s[1] for s in spd])
- pl.xticks(x + 0.5, [db.datamod_dict[k[0]] for k in spd], rotation=-10)
- pl.ylabel('Survey submissions per data modality\n(multiple choices per submission possible)')
- pl.savefig('%s/submissions_per_datamod.png' % destdir, format='png', dpi=80)
+ pl.title(title)
+ if not len(counts):
+ pl.text(.5, .5, "[Insufficient data for this figure]",
+ horizontalalignment='center')
+ pl.axis('off')
+ else:
+ # sort by name
+ if sortby == 'name':
+ stats = sorted(counts.items(), cmp=lambda x, y: cmp(x[0], y[0]))
+ elif sortby == 'count':
+ stats = sorted(counts.items(), cmp=lambda x, y: cmp(x[1], y[1]))[::-1]
+ else:
+ raise ValueError("Specify either name or count for sortby")
+ x = np.arange(len(stats))
+ pl.bar(x + (1./8), [s[1] for s in stats], width=0.75, color = '#008200')
+ pl.xticks(x + 0.5, ['' for s in stats])
+ for i, s in enumerate(stats):
+ pl.text(i+.5, 0.1, db.get_nice_name(s[0]), rotation=90,
+ horizontalalignment='center',
+ verticalalignment='bottom',
+ bbox=dict(facecolor='white', alpha=0.8, edgecolor='white'))
+ pl.xlim(0, len(stats))
+ yl = "Number of submissions"
+ if multiple:
+ yl += "\n(multiple choices per submission possible)"
+ pl.ylabel(yl)
+ pl.savefig('%s/submissions_per_%s.png' % (destdir, key), format='png', dpi=80)
+