User:VeryVerily/Contributions graph
From Wikipedia, the free encyclopedia
The contributions graph that was on my user page is made from the script below which I wrote in perl. It uses gnuplot to create the graph, and PNM tools to convert it to PNG format (without the latter you will still have a serviceable postscript file).
[edit] Instructions
Execute the script below with as input (either on standard input or as files on the command line) the raw HTML file with your list of user contributions (under "my contributions"). The caption assumes your time zone is set to 0 (UTC), although you could change that. If you have more than 5000 contributions, you will have to grab them in groups of 5000 (or less) due to Wikimedia limitations. The script will then create the following four files:
byhour-rep.dat byhour-nor.dat byhour.ps byhour.png
The first two are tables of hour of day vs. number of edits in that hour, with respectively repeats in the same hour of the same day counted and no repeats counted. The third is the graph as postscript, the fourth is the graph as a PNG file.
[edit] Script
($b, $x, @f) = ('byhour', '.dat', '-rep', '-nor'); @g = gmtime; $d = sprintf "%04d/%02d/%02d", 1900+$g[5], 1+$g[4], $g[3]; @w = <>; ($u)=(join' ',@w[0..60])=~/entSub\".*?User\:(\w+)/s; $u =~ s/_/ /g; $v[0] = [ @r = grep { /^\<li\>(.*?)\(/ and $_ = $1 and s/\:..\,// } @w ]; $v[1] = [ grep { $l ne $_ and $l = $_ } @r ]; for $i (0, 1) { my %h; for (@{$v[$i]}) { $h{substr($_,0,2)}++; } $h{24}=$h{'00'}; open K, "> $b$f[$i]$x"; for ('00'..'24') { print K "$_ ",$h{$_}||0,"\n"; } close K; } open K, "| gnuplot"; print K qq{ set nokey; set xlabel "$u, contributions by hour of day UTC, as of $d" set terminal postscript color solid 18 set output "$b.ps"; set xtics 1; set ytics 20; set format x "%02.f" plot "$b$f[0]$x" w l, "$b$f[1]$x" w l\n}; close K; system("pstopnm -stdout -xsize 400 $b.ps | pnmflip -r270 | pnmcrop | " . "pnmtopng -transparent white >$b.png");
[edit] Good luck!
I'd rather not provide too much tech support, so you should know a bit about what you're doing if you're going to use this.
I'd be interested to hear from anyone who is using this script. You might also consider linking to this page if you do.
Happy graphing!