当前位置: 首页>>代码示例>>Python>>正文


Python Select.create方法代码示例

本文整理汇总了Python中bokeh.models.Select.create方法的典型用法代码示例。如果您正苦于以下问题:Python Select.create方法的具体用法?Python Select.create怎么用?Python Select.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bokeh.models.Select的用法示例。


在下文中一共展示了Select.create方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_layout

# 需要导入模块: from bokeh.models import Select [as 别名]
# 或者: from bokeh.models.Select import create [as 别名]
    def create_layout(self):

        # create figure
        self.x_range = Range1d(start=self.model.map_extent[0],
                               end=self.model.map_extent[2], bounds=None)
        self.y_range = Range1d(start=self.model.map_extent[1],
                               end=self.model.map_extent[3], bounds=None)

        self.fig = Figure(tools='box_zoom,wheel_zoom,pan', x_range=self.x_range,
                          y_range=self.y_range)
        self.fig.plot_height = 600 
        self.fig.plot_width = 1024
        self.fig.axis.visible = True

        # add datashader layer
        self.image_source = ImageSource(url=self.model.service_url,
                                        extra_url_vars=self.model.shader_url_vars)
        self.image_renderer = DynamicImageRenderer(image_source=self.image_source)
        self.fig.renderers.append(self.image_renderer)

        # add ui components
        axes_select = Select.create(name='Plot:',
                                    options=self.model.axes)
        
        axes_select.on_change('value', self.on_axes_change)
        field_select = Select.create(name='Summary:', options=self.model.fields)
        
        field_select.on_change('value', self.on_field_change)
        
        aggregate_select = Select.create(name='Aggregation:',
            options=self.model.aggregate_functions)
        aggregate_select.on_change('value', self.on_aggregate_change)

        transfer_select = Select.create(name='Scale:',
            options=self.model.transfer_functions)
        transfer_select.on_change('value', self.on_transfer_function_change)

        controls = [axes_select, field_select, aggregate_select,
                    transfer_select]

        self.controls = VBox(width=200, height=600, children=controls)
        self.map_area = VBox(width=self.fig.plot_width, children=[self.fig])
        self.layout = HBox(width=self.fig.plot_width, children=[self.controls, self.map_area])
开发者ID:lsst-sqre,项目名称:bokeh-plots,代码行数:45,代码来源:app.py

示例2: OrderedDict

# 需要导入模块: from bokeh.models import Select [as 别名]
# 或者: from bokeh.models.Select import create [as 别名]
    new_data['image'] = [img.data]
    new_data['x'] = [x_range[0]]
    new_data['y'] = [y_range[0]]
    new_data['dh'] = [y_range[1] - y_range[0]]
    new_data['dw'] = [x_range[1] - x_range[0]]

    image_source.stream(new_data, 1)


time_select_options = OrderedDict()
time_select_options['1 Hour'] = 60
time_select_options['30 Minutes'] = 30
time_select_options['15 Minutes'] = 15
time_period = list(time_select_options.values())[0]

time_select = Select.create(name="Time Period", options=time_select_options)
time_select.on_change('value', on_time_select_change)

time_text = Paragraph(text='Time Period')

# load nyc taxi data
path = './data/nyc_taxi.csv'
datetime_field = 'tpep_dropoff_datetime'
cols = ['dropoff_x', 'dropoff_y', 'trip_distance', datetime_field]

df = pd.read_csv(path, usecols=cols, parse_dates=[datetime_field]).dropna(axis=0)
times = pd.DatetimeIndex(df[datetime_field])
group_count = grouped = groups = None
bin_data()

# manage client-side dimensions
开发者ID:brendancol,项目名称:datashader,代码行数:33,代码来源:streaming.py

示例3: create_layout

# 需要导入模块: from bokeh.models import Select [as 别名]
# 或者: from bokeh.models.Select import create [as 别名]
    def create_layout(self):

        # create figure
        self.x_range = Range1d(start=self.model.map_extent[0],
                               end=self.model.map_extent[2], bounds=None)
        self.y_range = Range1d(start=self.model.map_extent[1],
                               end=self.model.map_extent[3], bounds=None)

        self.fig = Figure(tools='wheel_zoom,pan',
                          x_range=self.x_range,
                          lod_threshold=None,
                          plot_width=self.model.plot_width,
                          plot_height=self.model.plot_height,
                          y_range=self.y_range)

        self.fig.min_border_top = 0
        self.fig.min_border_bottom = 10
        self.fig.min_border_left = 0
        self.fig.min_border_right = 0
        self.fig.axis.visible = False

        self.fig.xgrid.grid_line_color = None
        self.fig.ygrid.grid_line_color = None

        # add tiled basemap
        self.tile_source = WMTSTileSource(url=self.model.basemap)
        self.tile_renderer = TileRenderer(tile_source=self.tile_source)
        self.fig.renderers.append(self.tile_renderer)

        # add datashader layer
        self.image_source = ImageSource(url=self.model.service_url,
                                        extra_url_vars=self.model.shader_url_vars)
        self.image_renderer = DynamicImageRenderer(image_source=self.image_source)
        self.fig.renderers.append(self.image_renderer)

        # add label layer
        self.label_source = WMTSTileSource(url=self.model.labels_url)
        self.label_renderer = TileRenderer(tile_source=self.label_source)
        self.fig.renderers.append(self.label_renderer)

        # Add a hover tool
        hover_layer = HoverLayer()
        hover_layer.field_name = self.model.field_title
        hover_layer.is_categorical = self.model.field in self.model.categorical_fields
        self.fig.renderers.append(hover_layer.renderer)
        self.fig.add_tools(hover_layer.tool)
        self.model.hover_layer = hover_layer

        self.model.legend_side_vbox = VBox()
        self.model.legend_bottom_vbox = VBox()

        # add ui components
        controls = []
        axes_select = Select.create(name='Axes',
                                    options=self.model.axes)
        axes_select.on_change('value', self.on_axes_change)
        controls.append(axes_select)

        self.field_select = Select.create(name='Field', options=self.model.fields)
        self.field_select.on_change('value', self.on_field_change)
        controls.append(self.field_select)

        self.aggregate_select = Select.create(name='Aggregate',
                                              options=self.model.aggregate_functions)
        self.aggregate_select.on_change('value', self.on_aggregate_change)
        controls.append(self.aggregate_select)

        transfer_select = Select.create(name='Transfer Function',
                                        options=self.model.transfer_functions)
        transfer_select.on_change('value', self.on_transfer_function_change)
        controls.append(transfer_select)

        color_ramp_select = Select.create(name='Color Ramp', options=self.model.color_ramps)
        color_ramp_select.on_change('value', self.on_color_ramp_change)
        controls.append(color_ramp_select)

        spread_size_slider = Slider(title="Spread Size (px)", value=0, start=0,
                                    end=10, step=1)
        spread_size_slider.on_change('value', self.on_spread_size_change)
        controls.append(spread_size_slider)

        hover_size_slider = Slider(title="Hover Size (px)", value=8, start=4,
                                   end=30, step=1)
        hover_size_slider.on_change('value', self.on_hover_size_change)
        controls.append(hover_size_slider)

        controls.append(self.model.legend_side_vbox)

        # add map components
        basemap_select = Select.create(name='Basemap', value='Imagery',
                                       options=self.model.basemaps)
        basemap_select.on_change('value', self.on_basemap_change)

        image_opacity_slider = Slider(title="Opacity", value=100, start=0,
                                      end=100, step=1)
        image_opacity_slider.on_change('value', self.on_image_opacity_slider_change)

        basemap_opacity_slider = Slider(title="Basemap Opacity", value=100, start=0,
                                        end=100, step=1)
        basemap_opacity_slider.on_change('value', self.on_basemap_opacity_slider_change)
#.........这里部分代码省略.........
开发者ID:duakas,项目名称:NYC-Weather-vs-Taxi-analysis,代码行数:103,代码来源:dashboard.py

示例4: create_layout

# 需要导入模块: from bokeh.models import Select [as 别名]
# 或者: from bokeh.models.Select import create [as 别名]
    def create_layout(self):

        # create figure
        self.x_range = Range1d(start=self.model.map_extent[0],
                               end=self.model.map_extent[2], bounds=None)
        self.y_range = Range1d(start=self.model.map_extent[1],
                               end=self.model.map_extent[3], bounds=None)

        self.fig = Figure(tools='wheel_zoom,pan',
                          x_range=self.x_range,
                          lod_threshold=None,
                          plot_width=self.model.plot_width,
                          plot_height=self.model.plot_height,
                          y_range=self.y_range)

        self.fig.min_border_top = 0
        self.fig.min_border_bottom = 10
        self.fig.min_border_left = 0
        self.fig.min_border_right = 0
        self.fig.axis.visible = False

        self.fig.xgrid.grid_line_color = None
        self.fig.ygrid.grid_line_color = None
        
        # add tiled basemap
        self.tile_source = WMTSTileSource(url=self.model.basemap)
        self.tile_renderer = TileRenderer(tile_source=self.tile_source)
        self.fig.renderers.append(self.tile_renderer)

        # add datashader layer
        self.image_source = ImageSource(url=self.model.service_url,
                                        extra_url_vars=self.model.shader_url_vars)
        self.image_renderer = DynamicImageRenderer(image_source=self.image_source)
        self.fig.renderers.append(self.image_renderer)
        
        # add label layer
        self.label_source = WMTSTileSource(url=self.model.labels_url)
        self.label_renderer = TileRenderer(tile_source=self.label_source)
        self.fig.renderers.append(self.label_renderer)

        # Add a hover tool
        self.invisible_square = Square(x='x',
                                       y='y',
                                       fill_color=None,
                                       line_color=None, 
                                       size=self.model.hover_size)

        self.visible_square = Square(x='x',
                                     y='y', 
                                     fill_color='#79DCDE',
                                     fill_alpha=.5,
                                     line_color='#79DCDE', 
                                     line_alpha=1,
                                     size=self.model.hover_size)

        cr = self.fig.add_glyph(self.model.hover_source,
                                self.invisible_square,
                                selection_glyph=self.visible_square,
                                nonselection_glyph=self.invisible_square)

        code = "source.set('selected', cb_data['index']);"
        callback = CustomJS(args={'source': self.model.hover_source}, code=code)
        self.model.hover_tool = HoverTool(tooltips=[(self.model.fields.keys()[0], "@value")],
                                    callback=callback, 
                                    renderers=[cr], 
                                    mode='mouse')
        self.fig.add_tools(self.model.hover_tool)
        self.model.legend_side_vbox = VBox()
        self.model.legend_bottom_vbox = VBox()

        # add ui components
        controls = []
        axes_select = Select.create(name='Axes',
                                    options=self.model.axes)
        axes_select.on_change('value', self.on_axes_change)
        controls.append(axes_select)

        self.field_select = Select.create(name='Field', options=self.model.fields)
        self.field_select.on_change('value', self.on_field_change)
        controls.append(self.field_select)

        self.aggregate_select = Select.create(name='Aggregate',
                                         options=self.model.aggregate_functions)
        self.aggregate_select.on_change('value', self.on_aggregate_change)
        controls.append(self.aggregate_select)

        transfer_select = Select.create(name='Transfer Function',
                                        options=self.model.transfer_functions)
        transfer_select.on_change('value', self.on_transfer_function_change)
        controls.append(transfer_select)

        color_ramp_select = Select.create(name='Color Ramp', options=self.model.color_ramps)
        color_ramp_select.on_change('value', self.on_color_ramp_change)
        controls.append(color_ramp_select)

        spread_size_slider = Slider(title="Spread Size (px)", value=0, start=0,
                                        end=10, step=1)
        spread_size_slider.on_change('value', self.on_spread_size_change)
        controls.append(spread_size_slider)

#.........这里部分代码省略.........
开发者ID:fulQuan,项目名称:datashader,代码行数:103,代码来源:dashboard.py

示例5: create_layout

# 需要导入模块: from bokeh.models import Select [as 别名]
# 或者: from bokeh.models.Select import create [as 别名]
    def create_layout(self):

        # create figure
        self.x_range = Range1d(start=self.model.map_extent[0], end=self.model.map_extent[2], bounds=None)
        self.y_range = Range1d(start=self.model.map_extent[1], end=self.model.map_extent[3], bounds=None)

        self.fig = Figure(
            tools="wheel_zoom,pan",
            x_range=self.x_range,
            lod_threshold=None,
            plot_width=self.model.plot_width,
            plot_height=self.model.plot_height,
            background_fill_color="black",
            y_range=self.y_range,
        )

        self.fig.min_border_top = 0
        self.fig.min_border_bottom = 10
        self.fig.min_border_left = 0
        self.fig.min_border_right = 0
        self.fig.axis.visible = False

        self.fig.xgrid.grid_line_color = None
        self.fig.ygrid.grid_line_color = None

        # add tiled basemap
        self.tile_source = WMTSTileSource(url=self.model.basemap)
        self.tile_renderer = TileRenderer(tile_source=self.tile_source)
        self.fig.renderers.append(self.tile_renderer)

        # add datashader layer
        self.image_source = ImageSource(url=self.model.service_url, extra_url_vars=self.model.shader_url_vars)
        self.image_renderer = DynamicImageRenderer(image_source=self.image_source)
        self.fig.renderers.append(self.image_renderer)

        # add label layer
        self.label_source = WMTSTileSource(url=self.model.labels_url)
        self.label_renderer = TileRenderer(tile_source=self.label_source)
        self.fig.renderers.append(self.label_renderer)

        # Add placeholder for legends (temporarily disabled)
        # self.model.legend_side_vbox = VBox()
        # self.model.legend_bottom_vbox = VBox()

        # add ui components
        controls = []
        axes_select = Select.create(name="Axes", options=self.model.axes)
        axes_select.on_change("value", self.on_axes_change)
        controls.append(axes_select)

        self.field_select = Select.create(name="Field", options=self.model.fields)
        self.field_select.on_change("value", self.on_field_change)
        controls.append(self.field_select)

        self.aggregate_select = Select.create(name="Aggregate", options=self.model.aggregate_functions)
        self.aggregate_select.on_change("value", self.on_aggregate_change)
        controls.append(self.aggregate_select)

        transfer_select = Select.create(name="Transfer Function", options=self.model.transfer_functions)
        transfer_select.on_change("value", self.on_transfer_function_change)
        controls.append(transfer_select)

        color_ramp_select = Select.create(name="Color Ramp", options=self.model.color_ramps)
        color_ramp_select.on_change("value", self.on_color_ramp_change)
        controls.append(color_ramp_select)

        spread_size_slider = Slider(title="Spread Size (px)", value=0, start=0, end=10, step=1)
        spread_size_slider.on_change("value", self.on_spread_size_change)
        controls.append(spread_size_slider)

        hover_size_slider = Slider(title="Hover Size (px)", value=8, start=4, end=30, step=1)
        hover_size_slider.on_change("value", self.on_hover_size_change)
        controls.append(hover_size_slider)

        # legends (temporarily disabled)
        # controls.append(self.model.legend_side_vbox)

        # add map components
        basemap_select = Select.create(name="Basemap", value="Imagery", options=self.model.basemaps)
        basemap_select.on_change("value", self.on_basemap_change)

        image_opacity_slider = Slider(title="Opacity", value=100, start=0, end=100, step=1)
        image_opacity_slider.on_change("value", self.on_image_opacity_slider_change)

        basemap_opacity_slider = Slider(title="Basemap Opacity", value=100, start=0, end=100, step=1)
        basemap_opacity_slider.on_change("value", self.on_basemap_opacity_slider_change)

        show_labels_chk = CheckboxGroup(labels=["Show Labels"], active=[0])
        show_labels_chk.on_click(self.on_labels_change)

        map_controls = [basemap_select, basemap_opacity_slider, image_opacity_slider, show_labels_chk]

        self.controls = VBox(height=600, children=controls)
        self.map_controls = HBox(width=self.fig.plot_width, children=map_controls)

        # legends (temporarily disabled)
        self.map_area = VBox(width=900, height=600, children=[self.map_controls, self.fig])
        self.layout = HBox(width=1300, height=600, children=[self.controls, self.map_area])
        self.model.fig = self.fig
        self.model.update_hover()
开发者ID:philippjfr,项目名称:datashader,代码行数:102,代码来源:dashboard.py

示例6: create_layout

# 需要导入模块: from bokeh.models import Select [as 别名]
# 或者: from bokeh.models.Select import create [as 别名]
    def create_layout(self):

        # create figure
        self.x_range = Range1d(start=self.model.map_extent[0],
                               end=self.model.map_extent[2], bounds=None)
        self.y_range = Range1d(start=self.model.map_extent[1],
                               end=self.model.map_extent[3], bounds=None)

        self.fig = Figure(tools='wheel_zoom,pan', x_range=self.x_range,
                          y_range=self.y_range)
        self.fig.plot_height = 560
        self.fig.plot_width = 800
        self.fig.axis.visible = False

        # add tiled basemap
        self.tile_source = WMTSTileSource(url=self.model.basemap)
        self.tile_renderer = TileRenderer(tile_source=self.tile_source)
        self.fig.renderers.append(self.tile_renderer)

        # add datashader layer
        self.image_source = ImageSource(url=self.model.service_url,
                                        extra_url_vars=self.model.shader_url_vars)
        self.image_renderer = DynamicImageRenderer(image_source=self.image_source)
        self.fig.renderers.append(self.image_renderer)

        # add label layer
        self.label_source = WMTSTileSource(url=self.model.labels_url)
        self.label_renderer = TileRenderer(tile_source=self.label_source)
        self.fig.renderers.append(self.label_renderer)

        # add ui components
        axes_select = Select.create(name='Axes',
                                    options=self.model.axes)
        axes_select.on_change('value', self.on_axes_change)

        field_select = Select.create(name='Field', options=self.model.fields)
        field_select.on_change('value', self.on_field_change)

        aggregate_select = Select.create(name='Aggregate',
                                         options=self.model.aggregate_functions)
        aggregate_select.on_change('value', self.on_aggregate_change)

        transfer_select = Select.create(name='Transfer Function',
                                        options=self.model.transfer_functions)
        transfer_select.on_change('value', self.on_transfer_function_change)

        basemap_select = Select.create(name='Basemap', value='Toner',
                                       options=self.model.basemaps)
        basemap_select.on_change('value', self.on_basemap_change)

        image_opacity_slider = Slider(title="Opacity", value=100, start=0,
                                      end=100, step=1)
        image_opacity_slider.on_change('value', self.on_image_opacity_slider_change)

        basemap_opacity_slider = Slider(title="Basemap Opacity", value=100, start=0,
                                        end=100, step=1)
        basemap_opacity_slider.on_change('value', self.on_basemap_opacity_slider_change)

        show_labels_chk = CheckboxGroup(labels=["Show Labels"], active=[0])
        show_labels_chk.on_click(self.on_labels_change)


        controls = [axes_select, field_select, aggregate_select,
                    transfer_select]

        map_controls = [basemap_select, basemap_opacity_slider,
                        image_opacity_slider, show_labels_chk]

        self.controls = VBox(width=200, height=600, children=controls)
        self.map_controls = HBox(width=self.fig.plot_width, children=map_controls)
        self.map_area = VBox(width=self.fig.plot_width, children=[self.map_controls, self.fig])
        self.layout = HBox(width=1024, children=[self.controls, self.map_area])
开发者ID:sinhrks,项目名称:datashader,代码行数:74,代码来源:dashboard.py

示例7: AppModel

# 需要导入模块: from bokeh.models import Select [as 别名]
# 或者: from bokeh.models.Select import create [as 别名]
    figure.border_fill_color = model.background_fill
    figure.axis.axis_line_color = "white"
    figure.axis.axis_label_text_color = "white"
    figure.axis.major_label_text_color = "white"
    figure.axis.major_tick_line_color = "white"
    figure.axis.minor_tick_line_color = "white"
    figure.axis.minor_tick_line_color = "white"
    figure.grid.grid_line_dash = [6, 4]
    figure.grid.grid_line_alpha = .3
    return figure

model = AppModel(autompg)

controls_view = HBox(width=800)

x_select = Select.create(name='X-Axis', value=model.x_field, options=model.df.columns)
x_select.on_change('value', partial(bind_on_change, model_field='x_field'))

y_select = Select.create(name='Y-Axis', value=model.y_field, options=model.df.columns)
y_select.on_change('value', partial(bind_on_change, model_field='y_field'))

color_select = Select.create(name='Color', value=model.color_field, options=['None'] + model.quantileable_column_names)
color_select.on_change('value', partial(bind_on_change, model_field='color_field'))

palette_select = Select.create(name='Palette', options=sorted(model.palettes))
palette_select.on_change('value', partial(bind_on_change, model_field='palette_name'))

size_select = Select.create(name='Size', value=model.size_field, options=['None'] + model.quantileable_column_names)
size_select.on_change('value', partial(bind_on_change, model_field='size_field'))

controls_view.children = [x_select, y_select, color_select, palette_select, size_select]
开发者ID:AbhijeetSG,项目名称:bokeh,代码行数:33,代码来源:main.py


注:本文中的bokeh.models.Select.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。