Skip to content

Instantly share code, notes, and snippets.

@jtallieu
Created March 5, 2017 02:48
Show Gist options
  • Save jtallieu/117fb86525cbcfd6e9f2a4957001565f to your computer and use it in GitHub Desktop.
Save jtallieu/117fb86525cbcfd6e9f2a4957001565f to your computer and use it in GitHub Desktop.

Revisions

  1. jtallieu created this gist Mar 5, 2017.
    67 changes: 67 additions & 0 deletions plotter.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,67 @@
    import plotly.plotly as py
    from plotly import tools
    from plotly.graph_objs import *
    from plotly.offline import plot
    from numpy import *

    # Make a gradient pattern of 12 colors.
    N = 12
    colors = ['hsl('+str(h)+',50%'+',50%)' for h in linspace(0, 360, N)]


    def graph_ops(filename, data, offline=True):
    traces = []
    for count, series in enumerate(data['series']):
    traces.append(Bar(
    name="{} ops".format(series['name']),
    y = [series['name']],
    x = [series['total_ops']],
    orientation='h',
    marker=dict(color=colors[count])
    ))
    layout = Layout(
    title=data['title'],
    legend=dict(bordercolor="#444", bgcolor="#eee", borderwidth=1),
    margin=dict(b=100, l=150, t=80, r=150),
    yaxis=dict(
    title="Number of Greenlets",
    type="category",
    showline=True,
    showgrid=True,
    ),
    xaxis=dict(title="Total Operations", showline=True)
    )
    fig = Figure(data=traces, layout=layout)
    if offline:
    print plot(fig, filename=filename, auto_open=False, show_link=True)
    else:
    print py.plot(fig, filename=filename, auto_open=False, show_link=True)

    def graph_latency(filename, data, offline=True):
    traces = []
    for count, series in enumerate(data['series']):
    traces.append(Box(
    x = series['data'],
    name = series['name'],
    boxmean = True,
    marker=dict(color=colors[count])
    ))

    layout = Layout(
    title=data['title'],
    legend=dict(bordercolor="#444", bgcolor="#eee", borderwidth=1),
    margin=dict(b=100, l=150, t=80, r=150),
    yaxis=dict(
    title="Number of Greenlets",
    type="category",
    showline=True,
    showgrid=True,
    ),
    xaxis=dict(title="Latency (seconds)", showline=True)
    )

    fig = Figure(data=traces, layout=layout)
    if offline:
    print plot(fig, filename=filename, auto_open=False, show_link=True)
    else:
    print py.plot(fig, filename=filename, auto_open=False, show_link=True)