コード例 #1
0
ファイル: with_bokeh.py プロジェクト: biosustain/driven
    def scatter(self, dataframe, x=None, y=None, width=None, height=None, color=None, title=None,
                xaxis_label=None, yaxis_label=None, label=None):
        color = self.__default_options__.get('color', None) if color is None else color
        width = self.__default_options__.get('width', None) if width is None else width

        width, height = self._width_height(width, height)

        scatter = Scatter(dataframe, x=x, y=y, width=width, height=height, color=color, title=title,
                          tools=TOOLS + ',hover' if label else '')

        if label:
            hover = scatter.select_one(dict(type=HoverTool))
            hover.tooltips = [("Id", "@%s" % label)]
            renderer = scatter.select_one(dict(type=GlyphRenderer))
            renderer.data_source.data[label] = dataframe[label].tolist()

        if xaxis_label:
            scatter._xaxis.axis_label = xaxis_label
        if yaxis_label:
            scatter._yaxis.axis_label = yaxis_label

        return scatter
コード例 #2
0
    def scatter(self,
                dataframe,
                x=None,
                y=None,
                width=None,
                height=None,
                color=None,
                title=None,
                xaxis_label=None,
                yaxis_label=None,
                label=None):
        color = self.__default_options__.get('color',
                                             None) if color is None else color
        width = self.__default_options__.get('width',
                                             None) if width is None else width

        width, height = self._width_height(width, height)

        scatter = Scatter(dataframe,
                          x=x,
                          y=y,
                          width=width,
                          height=height,
                          color=color,
                          title=title,
                          tools=TOOLS + ',hover' if label else '')

        if label:
            hover = scatter.select_one(dict(type=HoverTool))
            hover.tooltips = [("Id", "@%s" % label)]
            renderer = scatter.select_one(dict(type=GlyphRenderer))
            renderer.data_source.data[label] = dataframe[label].tolist()

        if xaxis_label:
            scatter._xaxis.axis_label = xaxis_label
        if yaxis_label:
            scatter._yaxis.axis_label = yaxis_label

        return scatter
コード例 #3
0
p = figure(title="Texas Unemployment 2009",
           tools=TOOLS,
           x_axis_location=None,
           y_axis_location=None)
p.grid.grid_line_color = None

p.patches('x',
          'y',
          source=source,
          fill_color='color',
          fill_alpha=0.7,
          line_color="white",
          line_width=0.5)

hover = p.select_one(HoverTool)
hover.point_policy = "follow_mouse"
hover.tooltips = [
    ("Name", "@name"),
    ("Unemployment rate)", "@rate%"),
    ("(Long, Lat)", "($x, $y)"),
]

show(p)

import numpy as np
from bokeh.layouts import gridplot
from bokeh.plotting import figure, output_notebook, show
from bokeh.models import ColumnDataSource

N = 300