Index: trunk/tools/wsor/editor_lifecycle/plotpeak |
— | — | @@ -19,12 +19,15 @@ |
20 | 20 | parser.add_argument('data_paths', metavar='data', nargs='+') |
21 | 21 | parser.add_argument('-o', '--output', dest='output_path', metavar='FILE') |
22 | 22 | 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') |
23 | 26 | |
24 | 27 | date_parser = DateParser() |
25 | 28 | default_date = datetime(2001,1,1) |
26 | 29 | |
27 | 30 | markers = 'ov^<>sp*+xD' |
28 | | -colors = 'bgrcmykw' |
| 31 | +colors = 'brcmgykw' |
29 | 32 | conv = defaultdict(lambda k : float) |
30 | 33 | conv[0] = lambda k : date_parser.parse(k, default=default_date) |
31 | 34 | |
— | — | @@ -32,10 +35,15 @@ |
33 | 36 | ns = parser.parse_args() |
34 | 37 | |
35 | 38 | # 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)) |
39 | 40 | |
| 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 | + |
40 | 48 | M = len(markers) |
41 | 49 | C = len(colors) |
42 | 50 | |
— | — | @@ -62,30 +70,56 @@ |
63 | 71 | |
64 | 72 | label = os.path.splitext(path)[0].replace('_',' ') |
65 | 73 | |
66 | | -# color = colors[i % C] |
| 74 | + if ns.splitted: |
| 75 | + color = colors[i % C] |
| 76 | + else: |
| 77 | + color = 'red' |
| 78 | + |
67 | 79 | marker = markers[i % M] |
68 | 80 | 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', |
70 | 82 | ls='none', lw=2, mfc='none') |
71 | 83 | lines.append(l) |
72 | 84 | |
| 85 | + if ns.splitted: |
| 86 | + color = colors[i % C] |
| 87 | + else: |
| 88 | + color = 'blue' |
| 89 | + |
73 | 90 | 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) |
76 | 93 | |
77 | 94 | lines.append(l) |
78 | 95 | |
| 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 | + |
79 | 105 | # decorate figure |
80 | 106 | 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') |
83 | 114 | 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')) |
88 | 116 | |
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 | + |
90 | 124 | if ns.title is not None: |
91 | 125 | pp.title(ns.title) |
92 | 126 | pp.draw() |
Index: trunk/tools/wsor/editor_lifecycle/timechart |
— | — | @@ -71,7 +71,8 @@ |
72 | 72 | lines.append(l) |
73 | 73 | |
74 | 74 | # 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) |
76 | 77 | ax.axvline(xp, color=color) |
77 | 78 | |
78 | 79 | # plot spline |
Index: trunk/tools/wsor/editor_lifecycle/mrtchart |
— | — | @@ -56,7 +56,7 @@ |
57 | 57 | |
58 | 58 | # create figure and axis |
59 | 59 | 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')) |
61 | 61 | M = len(markers) |
62 | 62 | C = len(colors) |
63 | 63 | |
— | — | @@ -87,6 +87,8 @@ |
88 | 88 | pp.xlabel('') |
89 | 89 | pp.figlegend(ax.lines, [ l.get_label() for l in ax.lines ], |
90 | 90 | loc='center right', prop=FontProperties(size='small')) |
| 91 | + for label in ax.xaxis.get_ticklabels(): |
| 92 | + label.set_rotation(-20) |
91 | 93 | pp.minorticks_on() |
92 | 94 | pp.grid("on") |
93 | 95 | if ns.title is not None: |