Пример #1
0
def systemEvolutionBarPlot(df, yLabel, values):
    with Timer(key='systemEvolutionBarPlot', verbose=True):
        p = Bar(df, label='snapshot', values=values, agg='sum', stack='software',
            legend='bottom_left', bar_width=0.5, xlabel="Snapshots", ylabel=yLabel, responsive=True, height=200,tools='hover')

        glyph_renderers = p.select(GlyphRenderer)
        bar_source = [glyph_renderers[i].data_source for i in range(len(glyph_renderers))]
        hover = p.select(HoverTool)
        hover.tooltips = [
            ('software',' @software'),
            ('value', '@height'),
        ]
        p.xaxis.formatter=FuncTickFormatter.from_py_func(getWeekStringTick)
        p.axis.minor_tick_line_color = None

        p.background_fill_color = "#fafafa"
        p.legend.location = "top_left"
        p.toolbar.logo = None
        p.toolbar_location = None

        legend=p.legend[0].legends
        p.legend[0].legends=[]
        l = Legend( location=(0, -30))
        l.items=legend
        p.add_layout(l, 'right')

        return p
Пример #2
0
# hm10 = HeatMap(unempl, x='Year', y='Month', values='Unemployment', stat=None,
#               sort_dim={'x': False}, width=900, plot_height=500)

TOOLS = [BoxSelectTool(), HoverTool()]

hm11 = HeatMap(test, x='region', y='area', values='data', legend=False, stat=None, palette=GnRd9, width = 500, plot_height=500, title="Actlab Region Detection Test", tools=TOOLS)
hm12 = Bar(data_bar, values='dist', label='region', legend=False, title='Error Distance for Respective Regions', width = 800, plot_height = 500)
hm13 = BoxPlot(data_bar, values='dist', label='region', legend=False, title='Error Distance Boxplot', width = 300, plot_height=300)
#hm11.legend.location = 'right'
# data1 = [int(x) for x in data]
# print data1
# hover = HoverTool(tooltips=[
#   ("error", "@data1")])
# hm11.add_tools(hover)  
hm11.add_layout(labels)
hm11.add_layout(labels_dev)
hm12.add_layout(label_reg)
# output_file("heatmap.html")
output_file("Bar.html")
hm11.axis.visible = False
# show(hm11)
# show(hm12)
# show(hm13)



show(column(
   gridplot(hm11, hm12,
            ncols=1, plot_width=400, plot_height=400)
 ))
Пример #3
0
def portalDynamicity(df):

    def getWeekString(yearweek):
        if yearweek is None or len(str(yearweek)) == 0:
            return ''
        year = "'" + str(yearweek)[:2]
        week = int(str(yearweek)[2:])
        # d = d - timedelta(d.weekday())
        # dd=(week)*7
        # dlt = timedelta(days = dd)
        # first= d + dlt

        # dlt = timedelta(days = (week)*7)
        # last= d + dlt + timedelta(days=6)

        return 'W' + str(week) + '-' + str(year)
    bp = figure(plot_width=600, plot_height=300, y_axis_type="datetime", responsive=True,
                tools='')  # ,toolbar_location=None
    bp.toolbar.logo = None
    bp.toolbar_location = None
    label_dict={}
    for i, s in enumerate(df['snapshot']):
        label_dict[i] = getWeekString1(s)

    bp.yaxis[0].formatter = NumeralTickFormatter(format="0.0%")
    bp.xaxis[0].axis_label = 'Snapshots'
    bp.yaxis[0].axis_label = '% of portals'

    li = bp.line(df.index.values.tolist(), df['dyratio'], line_width=2, line_color='red', legend="dyratio")
    c = bp.circle(df.index.values.tolist(), df['dyratio'], line_width=2, line_color='red', legend="dyratio")
    li1 = bp.line(df.index.values.tolist(), df['adddelratio'], line_width=2, line_color='blue', legend="adddelratio")
    c = bp.circle(df.index.values.tolist(), df['adddelratio'], line_width=2, line_color='blue', legend="adddelratio")
    legend = bp.legend[0].legends
    bp.legend[0].legends = []
    l = Legend(location=(0, -30))
    l.items = legend
    bp.add_layout(l, 'right')



    labels=["staticRatio","updatedRatio","addRatio","delRatio"]
    #for l in labels:
    #    df[l]= df[l]*100
    print brewer.keys()
    colors = brewer["Pastel2"][len(labels)]
    bar = Bar(df,
              values=blend("staticRatio","updatedRatio","addRatio","delRatio", name='medals', labels_name='medal'),
              label=cat(columns='snapshot', sort=False),
              stack=cat(columns='medal', sort=False),
              color=color(columns='medal', palette=colors,
                          sort=False),
              legend='top_right',
              bar_width=0.5, responsive=True,
              tooltips=[('ratio', '@medal'), ('snapshot', '@snapshot'),('Value of Total',' @height{0.00%}')])
    legend = bar.legend[0].legends
    bar.legend[0].legends = []
    l = Legend(location=(0, -30))
    l.items = legend
    bar.add_layout(l, 'right')
    bar.xaxis[0].axis_label = 'Snapshots'
    bar.yaxis[0].axis_label = '% of datasets'
    bar.width=600
    bar.height=300
    bar.xaxis[0].formatter = FuncTickFormatter.from_py_func(getWeekStringTick)
    bar.toolbar.logo = None
    bar.toolbar_location = None

    bar.yaxis[0].formatter = NumeralTickFormatter(format="0.0%")
    return {'bar':bar,'lines':bp}