コード例 #1
0
ファイル: xapp.py プロジェクト: ContinuumIO/xdata-feat
def dashboard():
    """
    Creates the main app objects
    """
    # TODO: Should find a better design and remove those global objs...
    global source
    global csource

    source = ColumnDataSource(df)
    source.tags = ['main_source']

    csource = ColumnDataSource(cdf)
    csource.tags = ['crash_source']

    select_sec = Select.create(options=SECURITIES, name='select_sec', title="")

    asel = Select.create(options=df.columns, name='field_to_add', title="")
    chart_sel = Select.create(options=chart_types, name='chart_to_add', title="")

    msel = MultiSelect.create(options=[], name='ms')
    abutton = Button(label="add", type="success", name='add_button')
    rbutton = Button(label="remove", type="danger", name='remove_button')
    add_chart_button = Button(label="add chart", type="success", name='add_chart')


    data_table = DataTable(source=source, editable=True, width=500, height=400)
    ccolumns = [TableColumn(field=x, title=x, editor=NumberEditor()) for x in cdf.columns]
    crashes_table = DataTable(source=csource, editable=True, width=1200, height=400, columns=ccolumns)

    charts_box = AppVBox(children=[], name='charts_box')

    counts = cdf['crashes']
    crashes_hist = charts.Histogram({'crash_counts': counts}, bins=20, height=300, title="# Crashes per Symbol")
    crashes_scatter = create_crashes_scatter()

    main_tab = VBox(children=[], name='d_box')
    dlg = Dialog(buttons=[], content=main_tab , visible=False)

    options = CheckboxGroup(
        labels=['Show peaks', 'Show Std. Dev.', 'Bolinger Bands'],
        name='new_chart_options'
    )

    select_palette = Select.create(options=brewer.keys(), name='select_palette', title="Palette")
    return {
        # security tab
        'select_sec': select_sec,
        'field_to_add': asel,
        'chart_to_add': chart_sel,
        'ms': msel,
        'dt': data_table,
        'add_button': abutton,
        'remove_button': rbutton,
        'add_chart': add_chart_button,
        'charts_box': charts_box,
        'dlg': dlg,

        # Crashes tab objs
        'crashes_hist': crashes_hist,
        'crashes_scatter': crashes_scatter,
        'crashes_table': crashes_table,
        'crash_stats': PreText(text="NO CRASHES FOR SYMBOL %s" % SYMBOL, width=300),

        #
        'chart_values': MultiSelect.create(options=df.columns, name="chart_values", title="Values"),
        'new_chart_index': Select.create(options=['---']+list(df.columns), title="Chart index", name="new_chart_index"),
        'new_chart_title': TextInput(title="Chart Title", name='new_chart_title', value=''),
        'new_chart_options': options,
        'select_palette': select_palette,

        # ANNOTATIONS
        "annotations": MultiSelect.create(options=[], name="annotations", title="Annotations"),
        "add_annotation": Button(label="add", type="success", name='add_annotation'),
        "delete_annotation": Button(label="remove", type="danger", name='delete_annotation'),
        "show_annotation": Button(label="Show", type="link", name='show_annotation'),
        'new_annotation_dlg': Dialog(buttons=[], content=main_tab , visible=False),
        'annotation_txt': TextInput(title="New Annotation", name='annotation_txt', value=''),
        'new_annotation_options': CheckboxGroup(labels=[], name='new_annotation_options'),
    }
コード例 #2
0
ファイル: plots.py プロジェクト: ADEQUATeDQ/portalmonitor
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}
コード例 #3
0
from StringIO import StringIO

from collections import OrderedDict

import numpy as np
import pandas as pd

from bokeh.plotting import *
from bokeh.palettes import brewer
from bokeh.objects import HoverTool

import pdb

import click

palettes = u', '.join(sorted(brewer.keys()))

help = u"""Colors palette to use. The following palettes are available:

%s


You can also provide your own custom palette by specifying a list colors. I.e.:

"#a50026,#d73027,#f46d43,#fdae61,#fee08b,#ffffbf,#d9ef8b,#a6d96a,#66bd63"


""" % palettes


@click.command()
コード例 #4
0
ファイル: bokeh-cli.py プロジェクト: fpliger/bokeh-cli
from StringIO import StringIO

from collections import OrderedDict

import numpy as np
import pandas as pd

from bokeh.plotting import *
from bokeh.palettes import brewer
from bokeh.objects import HoverTool

import pdb

import click

palettes = u', '.join(sorted(brewer.keys()))

help = u"""Colors palette to use. The following palettes are available:

%s


You can also provide your own custom palette by specifying a list colors. I.e.:

"#a50026,#d73027,#f46d43,#fdae61,#fee08b,#ffffbf,#d9ef8b,#a6d96a,#66bd63"


""" % palettes

@click.command()
@click.option('--source_filename',
コード例 #5
0
    type=click.Path(dir_okay=False, writable=True),
    default="heatmap.html",
    show_default=True,
)
@click.option(
    "-d",
    "--delim",
    help="Delimiter used in the matrix. [ default: '\\t']",
    default="\t",
    # show_default=True,
)
@click.option(
    "-p",
    "--palette",
    help="ColorBrewer palette to use for heatmap.",
    type=click.Choice(choices=brewer.keys(), case_sensitive=True),
    default="RdBu",
    show_default=True,
)
@click.option("-t",
              "--title",
              help="Title for the heatmap.",
              default=TITLE,
              show_default=True)
@click.option("--width",
              help="Plot width in pixels",
              default=WIDTH,
              show_default=True)
@click.option("--height",
              help="Plot height in pixels",
              default=HEIGHT,
コード例 #6
0
                   counterclock=not rot_clock,
                   ax=ax,
                   **kwargs)
    if ax:
        ax.set(aspect="equal")
        if title:
            ax.set_title(title, fontsize=14)
    else:
        plt.axis('equal')
        if title:
            plt.title(title, fontsize=14)


# 色板

CMAP = ','.join(sorted(brewer.keys()))
pal = brewer
temp = {}

## 添加 反转 cmap
for cols in brewer:
    temp[cols + "_r"] = {}
    for i in brewer[cols]:
        temp[cols + "_r"][i] = brewer[cols][i]  #bokeh 的色板顺序和 seaborn 相反
        brewer[cols][i] = list(reversed(brewer[cols][i]))

brewer.update(temp)
del temp


def showPal(cmp=None):