Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

+ plot tool for mimetypes

  • Loading branch information...
commit 20e4db710ea4b196c7c8f327209d8593e0d5d1c7 1 parent 76bddb4
@erlehmann erlehmann authored
Showing with 48 additions and 0 deletions.
  1. +2 −0  README
  2. +46 −0 plot-helper
View
2  README
@@ -25,3 +25,5 @@ To use the upload feature of oa-put, copy the userconfig.example file to
“$HOME/config/open-access-media-importer/userconfig”.
A screencast showing usage can be played back with “ttyplay screencast”.
+
+To plot mimetypes occurring in sources, install python-matplotlib and pipe the output of “oa-cache stats [source]” to the included plot-helper script.
View
46 plot-helper
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+from sys import stdin, stderr
+from pylab import figure, suptitle, bar, barh, legend, gcf, savefig
+
+exec("stats = %s" % stdin.read())
+mimetypes = stats['mimetypes']
+# sort the values, zip and the * operator are used here for magic
+# see <http://docs.python.org/library/functions.html#zip>
+labels, values = zip(*sorted(mimetypes.iteritems(), key=lambda x: x[1]))
+
+fig1 = figure(figsize=(8,8))
+suptitle('Mimetypes of Supplementary Materials under Free Licenses')
+ax1 = fig1.add_subplot(1,1,1)
+
+# places labels for mimetypes
+ticks = range(len(labels))
+ax1.set_yticks(ticks)
+ax1.set_yticklabels(labels)
+
+ax1.set_xscale('log')
+
+colors = []
+basecolor = '#babdb6'
+videocolor = '#8ae234'
+audiocolor = '#729fcf'
+imagecolor = '#ad7fa8'
+for l in labels: # keys are the names of the boys
+ if l.startswith('video'):
+ colors.append(videocolor)
+ elif l.startswith('audio'):
+ colors.append(audiocolor)
+ elif l.startswith('image'):
+ colors.append(imagecolor)
+ else:
+ colors.append(basecolor)
+
+b1 = barh(ticks, values, color=colors, align='center')
+videobar = bar([0], [0], color=videocolor)
+audiobar = bar([0], [0], color=audiocolor)
+imagebar = bar([0], [0], color=imagecolor)
+legend([videobar, audiobar, imagebar], ['video', 'audio', 'image'])
+gcf().subplots_adjust(left=0.4)
+
+with open('mimetypes.png', 'w') as f:
+ savefig(f, format='png')
+ stderr.write('Wrote figure to mimetypes.png.\n')
Please sign in to comment.
Something went wrong with that request. Please try again.