示例#1
0
def draw(domlist, index, func, max, tick, name, log=False):

    if not log:
        n1 = "Wikisource_-_%s.png" % name
    else:
        n1 = "Wikisource_-_%s.log.png" % name

    fig = pylab.figure(1, figsize=(7, 7))
    ax = fig.add_subplot(111)

    pylab.clf()
    pylab.hold(True)
    pylab.grid(True)

    for dom in domlist:
        count = count_array[dom][index]
        if func:
            count = func(count, dom)
        if count:
            if not log:
                pylab.plot(count[1],
                           count[0],
                           '-',
                           color=colors[dom],
                           label=dom,
                           linewidth=1.5)
            else:
                pylab.semilogy(count[1],
                               count[0],
                               '-',
                               color=colors[dom],
                               label=dom,
                               linewidth=1.5)
                #pylab.xlabel("Days (since 9-24-2007)")

    ymin, ymax = pylab.ylim()

    pylab.plot_date(count[1], pylab.zeros(len(count[1])), 'k-')
    ax.xaxis.set_major_locator(pylab.YearLocator())
    ax.xaxis.set_major_formatter(pylab.DateFormatter('%Y-%m-%d'))
    fig.autofmt_xdate()

    if not log:
        if max:
            ymax = max
            xmax = int(pylab.xlim()[1] / 7)
            pylab.yticks(pylab.arange(0, max + 1, tick))

        pylab.ylim(ymin, ymax)
    else:
        pylab.ylim(100, ymax)

    pylab.legend(loc=2, ncol=2, prop={'size': 'small'})
    pylab.title(name.replace('_', ' '))
    pylab.savefig(savepath + n1)
    return
示例#2
0
def quickplot(x,year_mult=10,show=True,recess=False,save=False,name='file',width=2):

    '''Create a plot of a FRED data series'''

    fig = pylab.figure()

    years  = pylab.YearLocator(year_mult)
    ax = fig.add_subplot(111)
    ax.plot_date(x.datenums,x.data,'b-',lw=width)
    ax.xaxis.set_major_locator(years)
    ax.set_title(x.title)
    ax.set_ylabel(x.units)
    fig.autofmt_xdate()
    if recess != False:
        x.recessions()
    ax.grid(True)
    if show==True:
        pylab.show()
    if save !=False:
        fullname = name+'.png'
        fig.savefig(fullname,bbox_inches='tight')
示例#3
0
                          color=h[0].get_color(),
                          linestyle=':',
                          hold=True)
        else:
            print "== %s ==" % k
            for date, rate, path in v:
                stamp = time.strftime("%Y-%m-%d %H:%M:%S", date)
                print stamp, "%10.3f" % rate, path

    if plot:
        pylab.grid(which='y')
        ax = pylab.gca()
        days = ax.dataLim.xmax - ax.dataLim.xmin
        #print "days",days, ax.dataLim.xmin, ax.dataLim.xmax
        if days > 5 * 365:
            major = pylab.YearLocator(interval=1)
            minor = pylab.MonthLocator(interval=6)
            label = pylab.DateFormatter("'%y")
        elif days > 2 * 365:
            major = pylab.MonthLocator(interval=6)
            minor = pylab.MonthLocator(interval=3)
            label = pylab.DateFormatter("%b '%y")
        elif days > 365:
            major = pylab.MonthLocator(interval=3)
            minor = pylab.MonthLocator(interval=1)
            label = pylab.DateFormatter("%b '%y")
        elif days > 365 / 2:
            major = pylab.MonthLocator(interval=2)
            minor = pylab.MonthLocator(interval=1, bymonthday=(1, 15))
            label = pylab.DateFormatter("%b '%y")
        elif days > 365 / 6:
示例#4
0
def draw_domain(dom):

    n1 = "Wikisource_-_pages_%s.png" % dom
    fig = pylab.figure(1)
    ax = fig.add_subplot(111)

    pylab.clf()
    pylab.hold(True)
    pylab.grid(True)
    count = count_array[dom]
    pylab.fill_between(count[0][1], 0, count[0][0], facecolor="#ffa0a0")  #red
    pylab.fill_between(count[4][1], 0, count[4][0], facecolor="#b0b0ff")  #blue
    pylab.fill_between(count[3][1], 0, count[3][0], facecolor="#dddddd")  #gray
    pylab.fill_between(count[2][1], 0, count[2][0],
                       facecolor="#ffe867")  #yellow
    pylab.fill_between(count[1][1], 0, count[1][0],
                       facecolor="#90ff90")  #green

    x = range(1)
    b1 = pylab.bar(x, x, color='#ffa0a0')
    b0 = pylab.bar(x, x, color='#dddddd')
    b2 = pylab.bar(x, x, color='#b0b0ff')
    b3 = pylab.bar(x, x, color='#ffe867')
    b4 = pylab.bar(x, x, color='#90ff90')
    pylab.legend([b1[0], b3[0], b4[0], b0[0], b2[0]], [
        'not proofread', 'proofread', 'validated', 'without text',
        'problematic'
    ],
                 loc=2)

    pylab.plot_date(count[0][1], pylab.zeros(len(count[0][1])), 'k-')
    ax.xaxis.set_major_locator(pylab.YearLocator())
    ax.xaxis.set_major_formatter(pylab.DateFormatter('%Y-%m-%d'))
    fig.autofmt_xdate()

    pylab.title("%s.wikisource.org" % dom)
    pylab.ylim(0)
    pylab.savefig(savepath + n1)

    n1 = "Wikisource_-_texts_%s.png" % dom
    pylab.figure(1)
    pylab.clf()
    pylab.hold(True)
    pylab.grid(True)
    count = count_array[dom]
    pylab.fill_between(rm29(dom, count[8][1]),
                       0,
                       rm29(dom, count[8][0]),
                       facecolor="#b0b0ff")
    pylab.fill_between(rm29(dom, count[7][1]),
                       0,
                       rm29(dom, count[7][0]),
                       facecolor="#ffa0a0")
    pylab.fill_between(rm29(dom, count[9][1]),
                       0,
                       rm29(dom, count[9][0]),
                       facecolor="#dddddd")

    x = range(1)
    b1 = pylab.bar(x, x, color='#b0b0ff')
    b2 = pylab.bar(x, x, color='#ffa0a0')
    if dom != 'de':
        pylab.legend([b1[0], b2[0]], ['with scans', 'naked'], loc=3)
    else:
        pylab.legend([b1[0], b2[0]],
                     ['with transclusion (PR2)', 'older system (PR1)'],
                     loc=3)

    pylab.plot_date(rm29(dom, count[8][1]),
                    pylab.zeros(len(rm29(dom, count[8][1]))), 'k-')
    ax.xaxis.set_major_locator(pylab.YearLocator())
    ax.xaxis.set_major_formatter(pylab.DateFormatter('%Y-%m-%d'))
    fig.autofmt_xdate()

    pylab.title("%s.wikisource.org" % dom)
    pylab.ylim(0)
    pylab.savefig(savepath + n1)