def plot(name, events):
    svg = Scene(name)

    for ts, evt in events.items():

        targets, te = evt
        for t in targets:
            #print("%s: %d to %d" % (t, ts, te))

            # a different offset for each 'target'
            offset = plotting_order[t] * 10

            # simply draw a plain line between the two timestamps
            svg.add(Line((ts, offset), (te,offset)))

    svg.write_svg()
def plot_withmeness(name, observations, expectations, sliding_window = 30):
    svg = Scene(name)

    t_end = observations[observations.keys()[-1]][1]

    points = []

    delta = 1
    #delta = sliding_window

    for t_start in arange(0, t_end-sliding_window+1, delta):

            w = withmeness(observations, expectations, name = None, t_start=t_start, t_end=(t_start + sliding_window))
            #print("start: %s, end: %s -> %s" % (t_start, t_start + sliding_window, w))

            if w is not None:
                points.append((t_start,-(w * 100)))
                #points.append((t_start + delta,-(w * 100)))


    svg.add(Polyline(points))
    svg.write_svg()