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


Python plotting.figure方法代码示例

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


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

示例1: create

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import figure [as 别名]
def create(clz):
        """One-time creation of app's objects.

        This function is called once, and is responsible for
        creating all objects (plots, datasources, etc)
        """
        self = clz()
        n_vals = 1000
        self.source = ColumnDataSource(
            data=dict(
                top=[],
                bottom=0,
                left=[],
                right=[],
                x= np.arange(n_vals),
                values= np.random.randn(n_vals)
                ))

        # Generate a figure container
        self.stock_plot = clz.create_stock(self.source)
        self.update_data()
        self.children.append(self.stock_plot) 
开发者ID:mvaz,项目名称:osqf2015,代码行数:24,代码来源:stock.py

示例2: make_plot

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import figure [as 别名]
def make_plot(source, title):
    plot = figure(x_axis_type="datetime", plot_width=800, tools="", toolbar_location=None)
    plot.title.text = title

    plot.quad(top='record_max_temp', bottom='record_min_temp', left='left', right='right',
              color=Blues4[2], source=source, legend="Record")
    plot.quad(top='average_max_temp', bottom='average_min_temp', left='left', right='right',
              color=Blues4[1], source=source, legend="Average")
    plot.quad(top='actual_max_temp', bottom='actual_min_temp', left='left', right='right',
              color=Blues4[0], alpha=0.5, line_color="black", source=source, legend="Actual")

    # fixed attributes
    plot.xaxis.axis_label = None
    plot.yaxis.axis_label = "Temperature (F)"
    plot.axis.axis_label_text_font_style = "bold"
    plot.x_range = DataRange1d(range_padding=0.0)
    plot.grid.grid_line_alpha = 0.3

    return plot 
开发者ID:binder-examples,项目名称:bokeh,代码行数:21,代码来源:main.py

示例3: plot_histogram

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import figure [as 别名]
def plot_histogram(values, **kwargs):
    """
    Convenience function. Plots a histogram of flat 1D data.

    :param values:
    :return:
    """


    hist, edges = np.histogram(values, **kwargs)

    p1 = figure(tools="save")

    p1.quad(top=hist, bottom=0, left=edges[:-1], right=edges[1:],
            fill_color="#036564", line_color="#033649")


    return p1 
开发者ID:EPFL-LCSB,项目名称:pytfa,代码行数:20,代码来源:plotting.py

示例4: make_plot

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import figure [as 别名]
def make_plot(self, dataframe):
        self.source = ColumnDataSource(data=dataframe)
        self.plot = figure(
            x_axis_type="datetime", plot_width=600, plot_height=300,
            tools='', toolbar_location=None)
        self.plot.quad(
            top='max_temp', bottom='min_temp', left='left', right='right',
            color=Blues4[2], source=self.source, legend='Magnitude')
        line = self.plot.line(
            x='date', y='avg_temp', line_width=3, color=Blues4[1],
            source=self.source, legend='Average')
        hover_tool = HoverTool(tooltips=[
            ('Value', '$y'),
            ('Date', '@date_readable'),
        ], renderers=[line])
        self.plot.tools.append(hover_tool)

        self.plot.xaxis.axis_label = None
        self.plot.yaxis.axis_label = None
        self.plot.axis.axis_label_text_font_style = 'bold'
        self.plot.x_range = DataRange1d(range_padding=0.0)
        self.plot.grid.grid_line_alpha = 0.3

        self.title = Paragraph(text=TITLE)
        return column(self.title, self.plot) 
开发者ID:GoogleCloudPlatform,项目名称:bigquery-bokeh-dashboard,代码行数:27,代码来源:temperature.py

示例5: make_plot

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import figure [as 别名]
def make_plot(self, dataframe):
        self.source = ColumnDataSource(data=dataframe)
        palette = all_palettes['Set2'][6]
        hover_tool = HoverTool(tooltips=[
            ("Value", "$y"),
            ("Year", "@year"),
        ])
        self.plot = figure(
            plot_width=600, plot_height=300, tools=[hover_tool],
            toolbar_location=None)
        columns = {
            'pm10': 'PM10 Mass (µg/m³)',
            'pm25_frm': 'PM2.5 FRM (µg/m³)',
            'pm25_nonfrm': 'PM2.5 non FRM (µg/m³)',
            'lead': 'Lead (¹/₁₀₀ µg/m³)',
        }
        for i, (code, label) in enumerate(columns.items()):
            self.plot.line(
                x='year', y=code, source=self.source, line_width=3,
                line_alpha=0.6, line_color=palette[i], legend=label)

        self.title = Paragraph(text=TITLE)
        return column(self.title, self.plot)
# [END make_plot] 
开发者ID:GoogleCloudPlatform,项目名称:bigquery-bokeh-dashboard,代码行数:26,代码来源:air.py

示例6: make_plot

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import figure [as 别名]
def make_plot(self, dataframe):
        self.source = ColumnDataSource(data=dataframe)
        self.plot = figure(
            x_axis_type="datetime", plot_width=400, plot_height=300,
            tools='', toolbar_location=None)

        vbar = self.plot.vbar(
            x='date', top='prcp', width=1, color='#fdae61', source=self.source)
        hover_tool = HoverTool(tooltips=[
            ('Value', '$y'),
            ('Date', '@date_readable'),
        ], renderers=[vbar])
        self.plot.tools.append(hover_tool)

        self.plot.xaxis.axis_label = None
        self.plot.yaxis.axis_label = None
        self.plot.axis.axis_label_text_font_style = 'bold'
        self.plot.x_range = DataRange1d(range_padding=0.0)
        self.plot.grid.grid_line_alpha = 0.3

        self.title = Paragraph(text=TITLE)
        return column(self.title, self.plot) 
开发者ID:GoogleCloudPlatform,项目名称:bigquery-bokeh-dashboard,代码行数:24,代码来源:precipitation.py

示例7: app

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import figure [as 别名]
def app(doc):

    x,y = SineWave()
    source = ColumnDataSource(data=dict(x=x, y=y))

    import numpy as np # see TODO below about ranges
    plot = figure(plot_height=400, plot_width=400,
                  tools="crosshair,pan,reset,save,wheel_zoom",
                  x_range=[0, 4*np.pi], y_range=[-2.5, 2.5])
    plot.line('x', 'y', source=source, line_width=3, line_alpha=0.6)

    def update_sinewave(sw,**kw):
        x,y = sw()
        source.data = dict(x=x, y=y)
        # TODO couldn't figure out how to update ranges
        #plot.x_range.start,plot.x_range.end=pobj.x_range
        #plot.y_range.start,plot.y_range.end=pobj.y_range
    
    parambokeh.Widgets(SineWave, mode='server', doc=doc, callback=update_sinewave)
    doc.add_root(row(plot, width=800)) 
开发者ID:ioam,项目名称:parambokeh,代码行数:22,代码来源:bk_sliders.py

示例8: create_standard_figure

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import figure [as 别名]
def create_standard_figure(title, tooltips=None):
    """Return a styled, empty figure of predetermined height and width.

    Args:
        title (str): Title of the figure.
        tooltips (list): List of bokeh tooltips to add to the figure.

    Returns:
        fig (bokeh Figure)

    """
    fig = figure(plot_height=350, plot_width=700, title=title, tooltips=tooltips)
    fig.title.text_font_size = "15pt"
    fig.min_border_left = 50
    fig.min_border_right = 50
    fig.min_border_top = 20
    fig.min_border_bottom = 50
    fig.toolbar_location = None
    return fig 
开发者ID:OpenSourceEconomics,项目名称:estimagic,代码行数:21,代码来源:utilities.py

示例9: run

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import figure [as 别名]
def run(self):
        print("In thread.run")
        self.p = figure(plot_height=500, tools=TOOLS, y_axis_location='left', title=self.title)
        self.p.x_range.follow = "end"
        self.p.xaxis.axis_label = "Timestamp"
        self.p.x_range.follow_interval = 100
        self.p.x_range.range_padding = 0 
        self.p.line(x="timestamp", y="value", color="blue", source=self.source)
        self.p.circle(x="timestamp", y="value", color="red", source=self.source)

        self.session = push_session(curdoc())
        curdoc().add_periodic_callback(self.update, 100) #period in ms

        self.session.show(column(self.p)) 
        curdoc().title = 'Sensor' 
        self.session.loop_until_closed()

    # def register(self, d, sourceq):
    #     source = ColumnDataSource(dict(d))
    #     self.p.line(x=d[0], y=d[1], color="orange", source=source)
    #     curdoc().add_periodic_callback(self.update, 100) #period in ms 
开发者ID:mpi-sws-rse,项目名称:thingflow-python,代码行数:23,代码来源:bokeh.py

示例10: visualize_sentences

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import figure [as 别名]
def visualize_sentences(vecs, sentences, palette="Viridis256", filename="/notebooks/embedding/sentences.png",
                        use_notebook=False):
    tsne = TSNE(n_components=2)
    tsne_results = tsne.fit_transform(vecs)
    df = pd.DataFrame(columns=['x', 'y', 'sentence'])
    df['x'], df['y'], df['sentence'] = tsne_results[:, 0], tsne_results[:, 1], sentences
    source = ColumnDataSource(ColumnDataSource.from_df(df))
    labels = LabelSet(x="x", y="y", text="sentence", y_offset=8,
                      text_font_size="12pt", text_color="#555555",
                      source=source, text_align='center')
    color_mapper = LinearColorMapper(palette=palette, low=min(tsne_results[:, 1]), high=max(tsne_results[:, 1]))
    plot = figure(plot_width=900, plot_height=900)
    plot.scatter("x", "y", size=12, source=source, color={'field': 'y', 'transform': color_mapper}, line_color=None, fill_alpha=0.8)
    plot.add_layout(labels)
    if use_notebook:
        output_notebook()
        show(plot)
    else:
        export_png(plot, filename)
        print("save @ " + filename) 
开发者ID:ratsgo,项目名称:embedding,代码行数:22,代码来源:visualize_utils.py

示例11: visualize_words

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import figure [as 别名]
def visualize_words(words, vecs, palette="Viridis256", filename="/notebooks/embedding/words.png",
                    use_notebook=False):
    tsne = TSNE(n_components=2)
    tsne_results = tsne.fit_transform(vecs)
    df = pd.DataFrame(columns=['x', 'y', 'word'])
    df['x'], df['y'], df['word'] = tsne_results[:, 0], tsne_results[:, 1], list(words)
    source = ColumnDataSource(ColumnDataSource.from_df(df))
    labels = LabelSet(x="x", y="y", text="word", y_offset=8,
                      text_font_size="15pt", text_color="#555555",
                      source=source, text_align='center')
    color_mapper = LinearColorMapper(palette=palette, low=min(tsne_results[:, 1]), high=max(tsne_results[:, 1]))
    plot = figure(plot_width=900, plot_height=900)
    plot.scatter("x", "y", size=12, source=source, color={'field': 'y', 'transform': color_mapper}, line_color=None,
                 fill_alpha=0.8)
    plot.add_layout(labels)
    if use_notebook:
        output_notebook()
        show(plot)
    else:
        export_png(plot, filename)
        print("save @ " + filename) 
开发者ID:ratsgo,项目名称:embedding,代码行数:23,代码来源:visualize_utils.py

示例12: climate_map

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import figure [as 别名]
def climate_map():
    data = netCDF4.Dataset('data/Land_and_Ocean_LatLong1.nc')
    t = data.variables['temperature']
    image = get_slice(t, 1950, 1)

    world_countries = wc.data.copy()

    worldmap = pd.DataFrame.from_dict(world_countries, orient='index')

    # Create your plot
    p =  figure(width=900, height=500, x_axis_type=None, y_axis_type=None,
            x_range=[-180,180], y_range=[-90,90], toolbar_location="left")

    p.image_rgba(
        image=[image],
        x=[-180], y=[-90],
        dw=[360], dh=[180], name='image'
    )

    p.patches(xs=worldmap['lons'], ys=worldmap['lats'], fill_color="white", fill_alpha=0,
        line_color="black", line_width=0.5)

    return p 
开发者ID:chdoig,项目名称:scipy2015-blaze-bokeh,代码行数:25,代码来源:viz2.py

示例13: title

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import figure [as 别名]
def title():
    # Data 
    year = 1850
    month = 1

    years = [str(x) for x in np.arange(1850, 2015, 1)]

    months = [str(x) for x in np.arange(1, 13, 1)]
    months_str = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']

    month_str = months_str[month-1]

    title = figure(width=1200, height=100, x_range=(0, 1200), y_range=(0, 100), toolbar_location=None,
            x_axis_type=None, y_axis_type=None, outline_line_color="#FFFFFF", tools="", min_border=0)

    title.text(x=500, y=5, text=[month_str], text_font_size='36pt', text_color='black', 
        name="month", text_font="Georgia")
    title.text(x=350, y=5, text=[str(year)], text_font_size='36pt', text_color='black', 
        name="year",text_font="Georgia")

    return title 
开发者ID:chdoig,项目名称:scipy2015-blaze-bokeh,代码行数:23,代码来源:viz2.py

示例14: modify_doc

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import figure [as 别名]
def modify_doc(doc):
    df = sea_surface_temperature.copy()
    source = ColumnDataSource(data=df)

    plot = figure(x_axis_type='datetime', y_range=(0, 25), y_axis_label='Temperature (Celsius)',
                  title="Sea Surface Temperature at 43.18, -70.43")
    plot.line('time', 'temperature', source=source)

    def callback(attr, old, new):
        if new == 0:
            data = df
        else:
            data = df.rolling('{0}D'.format(new)).mean()
        source.data = ColumnDataSource(data=data).data

    slider = Slider(start=0, end=30, value=0, step=1, title="Smoothing by N Days")
    slider.on_change('value', callback)

    doc.add_root(column(slider, plot))

    # doc.theme = Theme(filename="theme.yaml") 
开发者ID:pythonstock,项目名称:stock,代码行数:23,代码来源:tornado_bokeh_embed.py

示例15: show

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import figure [as 别名]
def show(plot_to_show):
    """Display a plot, either interactive or static.

    Parameters
    ----------
    plot_to_show: Output of a plotting command (matplotlib axis or bokeh figure)
        The plot to show

    Returns
    -------
    None
    """
    if isinstance(plot_to_show, plt.Axes):
        show_static()
    elif isinstance(plot_to_show, bpl.Figure):
        show_interactive(plot_to_show)
    else:
        raise ValueError(
            "The type of ``plot_to_show`` was not valid, or not understood."
        ) 
开发者ID:lmcinnes,项目名称:umap,代码行数:22,代码来源:plot.py


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