File:Wikipedia article assessment graph (top decile).svg

Summary
Complete script to generate (2-clause BSD-licensed):
 * Other information:


 * 1) !/usr/bin/python
 * 2) Copyright (c) 2014, Facing the Sky
 * 3) All rights reserved.


 * 1) Redistribution and use in source and binary forms, with or without
 * 2) modification, are permitted provided that the following conditions are met:


 * 1) 1. Redistributions of source code must retain the above copyright notice, this
 * 2)    list of conditions and the following disclaimer.
 * 3) 2. Redistributions in binary form must reproduce the above copyright notice,
 * 4)    this list of conditions and the following disclaimer in the documentation
 * 5)    and/or other materials provided with the distribution.


 * 1) THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * 2) ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * 3) WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * 4) DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
 * 5) ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * 6) (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * 7) LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * 8) ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * 9) (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * 10) SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from lxml import etree import pandas as pd from matplotlib import pyplot as plt import re import numpy as np import datetime import requests

classes = [('Stub', '#ff6666'), ('Start', '#ffaa66'), ('C', '#ffff66'), ('B', '#b2ff66'), ('GA', '#66ff66'), ('A', '#66ffff'), ('FA', '#6699ff'), ]
 * 1) Note order: this goes bottom-to-top.

TOTAL_PAT = re.compile(r"^\|\| (\d{1,3}(,\d{3})*)") CLASS_PAT = re.compile(r"^\| \{\{(%s)-Class\}\}" % "|".join(cls for cls, colour in classes))

def munge(text): cls = None seen = {} for line in text.split("\n"): if cls is not None: m = TOTAL_PAT.match(line) if m is not None: num = int(m.group(1).replace(",", "")) seen[cls] = num cls = None continue m = CLASS_PAT.match(line) if m is not None: if cls is not None: return None cls = m.group(1) if cls in seen: return None if set(seen.keys) != set(cls for cls, colour in classes): return None tot = float(sum(seen.values)) return dict((k, v / tot) for k, v in seen.items)

data = []

buggy_revs = set(['494008070', '494007960'])

last_rev_date = '2010-02-07T23:07:10Z' while True: r = requests.post('http://en.wikipedia.org/w/index.php', params = {'title': 'Special:Export', 'pages': 'User:WP_1.0_bot/Tables/OverallArticles', 'offset': last_rev_date, 'limit': 1000, 'action': 'submit'}) r.raise_for_status root = etree.fromstring(r.text) revs = root.findall("{http://www.mediawiki.org/xml/export-0.8/}page/{http://www.mediawiki.org/xml/export-0.8/}revision") for rev in revs: if rev.find("{http://www.mediawiki.org/xml/export-0.8/}id").text in buggy_revs: continue text = rev.find("{http://www.mediawiki.org/xml/export-0.8/}text").text row = munge(text) if row is None: continue last_rev_date = rev.find("{http://www.mediawiki.org/xml/export-0.8/}timestamp").text date = row['date'] = np.datetime64(pd.datetools.parse(last_rev_date)) data.append(row) if len(revs) < 1000: break

df = pd.DataFrame.from_records(data, columns = ["date"] + list(cls for cls, colour in classes))

fig, ax = plt.subplots

ax.stackplot(df['date'], df[list(cls for cls, colour in classes)].transpose, colors = [colour for cls, colour in classes], linewidths = 0) ax.set_ylim(0, 1)

plt.savefig("res_full.svg")

ax.set_ylim(0.9, 1) plt.savefig("res_top_decile.svg")

See File:Wikipedia article assessment graph.svg for the full graph.