In [1]:
####Load Modules & Build DataFrames
project_dir = "/home/ubuntu/github/AstroWeekStudy/python_code/"

import sys
sys.path.append("/home/ubuntu/github/AstroWeekStudy/python_code/")

try:
    reload(loadData)
    reload(astroWeekLib)
except:
    import loadData
    import astroWeekLib
    
from loadData import *
from astroWeekLib import *


df,df2014,df2015,resampled = build_main_df()
df_users_created = prepareUserDf(df)
df_repos_created = build_df_repos_created(df2014)

event_types = df['type'].unique
astro_dt = [255]

In [3]:


In [6]:
#for i,e in enumerate(event_types):
#    s = resampled['event_types'][e].sum()
#    print i,e,s, len(resampled['event_types'][e])

In [6]:
event_types = np.unique(df.type.values)
event_types_short = ['CreateEvent','PushEvent','PullRequestEvent','CommitCommentEvent','IssuesEvent','IssueCommentEvent','ForkEvent','WatchEvent']
color = ['yellow','cyan','green','lime','red','pink','black','goldenrod']

pl.figure(1,(15,6))
y_old = np.zeros_like(resampled['event_types']['PushEvent'].values)
x = np.arange(len(y_old))

countAllEvents = np.array(map(float,resampled['event_types']['all'].values))


ratio = False

for i,e in enumerate(event_types_short):
    print i,e
    if ratio:
        y = resampled['event_types'][e].values / countAllEvents
        pl.bar(x,y,width=1,bottom=y_old,lw=0.1,color=color[i],label=e)
        y_old = y_old + y
        pl.ylim(ymax=2)
    else:
        y = resampled['event_types'][e].values
        y[y < 1] = 1
        ly = np.log10(y)
        pl.bar(x,ly,width=1,bottom=y_old,lw=0.1,color=color[i],label=e)
        y_old = y_old + ly
        pl.ylim(ymax=10)

y = resampled['event_types']['all'].values
y = (y)/np.std(y)
#pl.plot(x,y,label="all")
pl.xlim(astro_dt[0]-100,366)
pl.ylim(ymax=8)
#pl.legend(["all"] + event_types_short ,loc=0)
pl.legend(event_types_short ,loc=0)
pl.ylabel("log10(Count Events)")
pl.xlabel("Time [days since Jan. 1, 2014]")


0 CreateEvent
1 PushEvent
2 PullRequestEvent
3 CommitCommentEvent
4 IssuesEvent
5 IssueCommentEvent
6 ForkEvent
7 WatchEvent
Out[6]:
<matplotlib.text.Text at 0x959dd50>
Traceback (most recent call last):

  File "/usr/local/lib/python2.7/dist-packages/IPython/kernel/zmq/ipkernel.py", line 389, in execute_request
    shell.run_cell(code, store_history=store_history, silent=silent)

  File "/usr/local/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 2743, in run_cell
    self.events.trigger('post_execute')

  File "/usr/local/lib/python2.7/dist-packages/IPython/core/events.py", line 82, in trigger
    func(*args, **kwargs)

  File "/usr/local/lib/python2.7/dist-packages/IPython/kernel/zmq/pylab/backend_inline.py", line 118, in flush_figures
    return show(True)

  File "/usr/local/lib/python2.7/dist-packages/IPython/kernel/zmq/pylab/backend_inline.py", line 43, in show
    display(figure_manager.canvas.figure)

  File "/usr/local/lib/python2.7/dist-packages/IPython/core/display.py", line 131, in display
    format_dict, md_dict = format(obj, include=include, exclude=exclude)

  File "/usr/local/lib/python2.7/dist-packages/IPython/core/formatters.py", line 200, in format
    data = formatter(obj)

  File "<string>", line 2, in __call__

  File "/usr/local/lib/python2.7/dist-packages/IPython/core/formatters.py", line 233, in warn_format_error
    r = method(self, *args, **kwargs)

  File "/usr/local/lib/python2.7/dist-packages/IPython/core/formatters.py", line 350, in __call__
    return printer(obj)

  File "/usr/local/lib/python2.7/dist-packages/IPython/core/pylabtools.py", line 222, in <lambda>
    png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))

  File "/usr/local/lib/python2.7/dist-packages/IPython/core/pylabtools.py", line 132, in print_figure
    fig.canvas.print_figure(bytes_io, **kw)

  File "/usr/lib/pymodules/python2.7/matplotlib/backend_bases.py", line 2021, in print_figure
    **kwargs)

  File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_agg.py", line 469, in print_png
    FigureCanvasAgg.draw(self)

  File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_agg.py", line 421, in draw
    self.figure.draw(self.renderer)

  File "/usr/lib/pymodules/python2.7/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)

  File "/usr/lib/pymodules/python2.7/matplotlib/figure.py", line 898, in draw
    func(*args)

  File "/usr/lib/pymodules/python2.7/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)

  File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 1997, in draw
    a.draw(renderer)

  File "/usr/lib/pymodules/python2.7/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)

  File "/usr/lib/pymodules/python2.7/matplotlib/patches.py", line 405, in draw
    transform = self.get_transform()

  File "/usr/lib/pymodules/python2.7/matplotlib/patches.py", line 167, in get_transform
    return self.get_patch_transform() + artist.Artist.get_transform(self)

  File "/usr/lib/pymodules/python2.7/matplotlib/patches.py", line 547, in get_patch_transform
    self._update_patch_transform()

  File "/usr/lib/pymodules/python2.7/matplotlib/patches.py", line 542, in _update_patch_transform
    height = self.convert_yunits(self._height)

  File "/usr/lib/pymodules/python2.7/matplotlib/artist.py", line 159, in convert_yunits
    return ax.yaxis.convert_units(y)

  File "/usr/lib/pymodules/python2.7/matplotlib/axis.py", line 1328, in convert_units
    self.converter = munits.registry.get_converter(x)

  File "/usr/lib/pymodules/python2.7/matplotlib/units.py", line 117, in get_converter
    def get_converter(self, x):

KeyboardInterrupt

In [ ]: