r95379 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95378‎ | r95379 | r95380 >
Date:06:40, 24 August 2011
Author:giovanni
Status:deferred
Tags:
Comment:
small fixes to plotting scripts
Modified paths:
  • /trunk/tools/wsor/editor_lifecycle/mrtchart (modified) (history)
  • /trunk/tools/wsor/editor_lifecycle/plotpeak (modified) (history)
  • /trunk/tools/wsor/editor_lifecycle/timechart (modified) (history)

Diff [purge]

Index: trunk/tools/wsor/editor_lifecycle/plotpeak
@@ -19,12 +19,15 @@
2020 parser.add_argument('data_paths', metavar='data', nargs='+')
2121 parser.add_argument('-o', '--output', dest='output_path', metavar='FILE')
2222 parser.add_argument('-T', '--title')
 23+parser.add_argument('-s', '--splitted', action='store_true')
 24+parser.add_argument('-y', '--stretch-ylim', action='store_true', help='works'
 25+ ' only in twin-axes mode')
2326
2427 date_parser = DateParser()
2528 default_date = datetime(2001,1,1)
2629
2730 markers = 'ov^<>sp*+xD'
28 -colors = 'bgrcmykw'
 31+colors = 'brcmgykw'
2932 conv = defaultdict(lambda k : float)
3033 conv[0] = lambda k : date_parser.parse(k, default=default_date)
3134
@@ -32,10 +35,15 @@
3336 ns = parser.parse_args()
3437
3538 # create figure
36 - fig = pp.figure(figsize=(10,4))
37 - ax1 = fig.add_axes(pp.axes([.1,.15,.65,.75], axisbg='ghostwhite'))
38 - ax2 = ax1.twinx()
 39+ fig = pp.figure(figsize=(12,4))
3940
 41+ if ns.splitted:
 42+ ax1 = fig.add_subplot(121)
 43+ ax2 = fig.add_subplot(122)
 44+ else:
 45+ ax1 = fig.add_axes(pp.axes([.1,.15,.65,.75], axisbg='ghostwhite'))
 46+ ax2 = ax1.twinx()
 47+
4048 M = len(markers)
4149 C = len(colors)
4250
@@ -62,30 +70,56 @@
6371
6472 label = os.path.splitext(path)[0].replace('_',' ')
6573
66 -# color = colors[i % C]
 74+ if ns.splitted:
 75+ color = colors[i % C]
 76+ else:
 77+ color = 'red'
 78+
6779 marker = markers[i % M]
6880 l, (wu, wd), mc = ax1.errorbar(date, peak_date, peak_date_err / 2.0,
69 - marker=marker, mec='red', label=label, ecolor='lightgrey',
 81+ marker=marker, mec=color, label=label, ecolor='lightgrey',
7082 ls='none', lw=2, mfc='none')
7183 lines.append(l)
7284
 85+ if ns.splitted:
 86+ color = colors[i % C]
 87+ else:
 88+ color = 'blue'
 89+
7390 l, (wu, wd), mc = ax2.errorbar(date, peak, peak_err / 2.0,
74 - marker=marker, mec='blue', label=label, ecolor='lightgrey',
75 - ls='none', lw=2, mfc='none')
 91+ marker=marker, mec=color, label=label, ecolor='lightgrey',
 92+ ls='none', lw=2, mfc='none', color=color)
7693
7794 lines.append(l)
7895
 96+ if not ns.splitted and ns.stretch_ylim:
 97+ ym1, yM1 = ax1.get_ylim()
 98+ d1 = (yM1 - ym1) * .3
 99+ ax1.set_ylim(ym1, yM1 + d1)
 100+
 101+ ym2, yM2 = ax2.get_ylim()
 102+ d2 = (yM2 - ym2) * .3
 103+ ax2.set_ylim(ym2 - d2, yM2)
 104+
79105 # decorate figure
80106 ax1.set_xlabel('cohorts')
81 - ax1.set_ylabel('peak day', color='red')
82 - ax2.set_ylabel('peak edits/day', color='blue')
 107+
 108+ if ns.splitted:
 109+ ax1.set_ylabel('peak day')
 110+ ax2.set_ylabel('peak value (edits/day)')
 111+ else:
 112+ ax1.set_ylabel('peak day', color='red')
 113+ ax2.set_ylabel('peak value (edits/day)', color='blue')
83114 pp.figlegend(lines, [ l.get_label() for l in lines ],
84 - loc='center right', prop=FontProperties(size='small'))
85 - pp.minorticks_on()
86 - pp.grid("on")
87 - pp.axis('tight')
 115+ loc='upper right', prop=FontProperties(size='small'))
88116
89 - pp.draw()
 117+ ax1.minorticks_on()
 118+ ax1.grid("on")
 119+
 120+ if ns.splitted:
 121+ ax2.minorticks_on()
 122+ ax2.grid("on")
 123+
90124 if ns.title is not None:
91125 pp.title(ns.title)
92126 pp.draw()
Index: trunk/tools/wsor/editor_lifecycle/timechart
@@ -71,7 +71,8 @@
7272 lines.append(l)
7373
7474 # compute maximum
75 - xp, xperr, s, ests = find_peak(days, rate, rate_err)
 75+ (xp, yp), (xperr, yperr), s, ests = find_peak(days, rate, rate_err,
 76+ reps=0)
7677 ax.axvline(xp, color=color)
7778
7879 # plot spline
Index: trunk/tools/wsor/editor_lifecycle/mrtchart
@@ -56,7 +56,7 @@
5757
5858 # create figure and axis
5959 fig = pp.figure(figsize=(10,4))
60 - ax = fig.add_axes(pp.axes([.1,.1,.65,.8], axisbg='ghostwhite'))
 60+ ax = fig.add_axes(pp.axes([.1,.15,.65,.75], axisbg='ghostwhite'))
6161 M = len(markers)
6262 C = len(colors)
6363
@@ -87,6 +87,8 @@
8888 pp.xlabel('')
8989 pp.figlegend(ax.lines, [ l.get_label() for l in ax.lines ],
9090 loc='center right', prop=FontProperties(size='small'))
 91+ for label in ax.xaxis.get_ticklabels():
 92+ label.set_rotation(-20)
9193 pp.minorticks_on()
9294 pp.grid("on")
9395 if ns.title is not None:

Status & tagging log