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


Python plotting.ColumnDataSource方法代码示例

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


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

示例1: prepare_bls_datasource

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import ColumnDataSource [as 别名]
def prepare_bls_datasource(result, loc):
    """Prepare a bls result for bokeh plotting

    Parameters
    ----------
    result : BLS.model result
        The BLS model result to use
    loc : int
        Index of the "best" period. (Usually the max power)

    Returns
    -------
    bls_source : Bokeh.plotting.ColumnDataSource
        Bokeh style source for plotting
    """
    bls_source = ColumnDataSource(data=dict(
                                        period=result['period'],
                                        power=result['power'],
                                        depth=result['depth'],
                                        duration=result['duration'],
                                        transit_time=result['transit_time']))
    bls_source.selected.indices = [loc]
    return bls_source 
开发者ID:KeplerGO,项目名称:lightkurve,代码行数:25,代码来源:interact_bls.py

示例2: prepare_folded_datasource

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import ColumnDataSource [as 别名]
def prepare_folded_datasource(folded_lc):
    """Prepare a FoldedLightCurve object for bokeh plotting.

    Parameters
    ----------
    folded_lc : lightkurve.FoldedLightCurve
        The folded lightcurve

    Returns
    -------
    folded_source : Bokeh.plotting.ColumnDataSource
        Bokeh style source for plotting
    """
    folded_src = ColumnDataSource(data=dict(
                                  phase=np.sort(folded_lc.time),
                                  flux=folded_lc.flux[np.argsort(folded_lc.time)]))
    return folded_src


# Helper functions for help text... 
开发者ID:KeplerGO,项目名称:lightkurve,代码行数:22,代码来源:interact_bls.py

示例3: prepare_tpf_datasource

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import ColumnDataSource [as 别名]
def prepare_tpf_datasource(tpf, aperture_mask):
    """Prepare a bokeh DataSource object for selection glyphs

    Parameters
    ----------
    tpf : TargetPixelFile
        TPF to be shown.
    aperture_mask : boolean numpy array
        The Aperture mask applied at the startup of interact

    Returns
    -------
    tpf_source : bokeh.plotting.ColumnDataSource
        Bokeh object to be shown.
    """
    npix = tpf.flux[0, :, :].size
    pixel_index_array = np.arange(0, npix, 1).reshape(tpf.flux[0].shape)
    xx = tpf.column + np.arange(tpf.shape[2])
    yy = tpf.row + np.arange(tpf.shape[1])
    xa, ya = np.meshgrid(xx, yy)
    tpf_source = ColumnDataSource(data=dict(xx=xa.astype(float), yy=ya.astype(float)))
    tpf_source.selected.indices = pixel_index_array[aperture_mask].reshape(-1).tolist()
    return tpf_source 
开发者ID:KeplerGO,项目名称:lightkurve,代码行数:25,代码来源:interact.py

示例4: get_lightcurve_y_limits

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import ColumnDataSource [as 别名]
def get_lightcurve_y_limits(lc_source):
    """Compute sensible defaults for the Y axis limits of the lightcurve plot.

    Parameters
    ----------
    lc_source : bokeh.plotting.ColumnDataSource
        The lightcurve being shown.

    Returns
    -------
    ymin, ymax : float, float
        Flux min and max limits.
    """
    with warnings.catch_warnings():  # Ignore warnings due to NaNs
        warnings.simplefilter("ignore", AstropyUserWarning)
        flux = sigma_clip(lc_source.data['flux'], sigma=5, masked=False)
    low, high = np.nanpercentile(flux, (1, 99))
    margin = 0.10 * (high - low)
    return low - margin, high + margin 
开发者ID:KeplerGO,项目名称:lightkurve,代码行数:21,代码来源:interact.py

示例5: create_bar_plot

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import ColumnDataSource [as 别名]
def create_bar_plot(init_data, title):
    init_data = downsample(init_data, 50)
    x = range(len(init_data))
    source = ColumnDataSource(data=dict(x= [], y=[]))
    fig = figure(title=title, plot_width=300, plot_height=300)
    fig.vbar(x=x, width=1, top=init_data, fill_alpha=0.05)
    fig.vbar('x', width=1, top='y', fill_alpha=0.3, source=source)
    fig.y_range = Range1d(min(0, 1.2 * min(init_data)), 1.2 * max(init_data))
    return fig, source 
开发者ID:MarcusOlivecrona,项目名称:REINVENT,代码行数:11,代码来源:main.py

示例6: create_hist_plot

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import ColumnDataSource [as 别名]
def create_hist_plot(init_data, title):
    source = ColumnDataSource(data=dict(hist=[], left_edge=[], right_edge=[]))
    init_hist, init_edge = np.histogram(init_data, density=True, bins=50)
    fig = figure(title=title, plot_width=300, plot_height=300)
    fig.quad(top=init_hist, bottom=0, left=init_edge[:-1], right=init_edge[1:],
            fill_alpha=0.05)
    fig.quad(top='hist', bottom=0, left='left_edge', right='right_edge',
            fill_alpha=0.3, source=source)
    return fig, source 
开发者ID:MarcusOlivecrona,项目名称:REINVENT,代码行数:11,代码来源:main.py

示例7: prepare_bls_help_source

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import ColumnDataSource [as 别名]
def prepare_bls_help_source(bls_source, slider_value):
    data = dict(period=[bls_source.data['period'][int(slider_value*0.95)]],
                power=[(np.max(bls_source.data['power']) - np.min(bls_source.data['power'])) * 0.98 + np.min(bls_source.data['power'])],
                helpme=['?'],
                help=["""
                             <div style="width: 375px;">
                                 <div style="height: 190px;">
                                 </div>
                                 <div>
                                     <span style="font-size: 12px; font-weight: bold;">Box Least Squares Periodogram</span>
                                 </div>
                                 <div>
                                     <span style="font-size: 11px;"">This panel shows the BLS periodogram for
                                      the light curve shown in the lower panel.
                                     The current selected period is highlighted by the red line.
                                     The selected period is the peak period within the range.
                                     The Folded Light Curve panel [right] will update when a new period
                                     is selected in the BLS Panel. You can select a new period either by
                                     using the Box Zoom tool to select a smaller range, or by clicking on the peak you want to select. </span>
                                     <br></br>
                                     <span style="font-size: 11px;"">The panel is set at the resolution
                                     given by the Resolution Slider [bottom]. This value is the number
                                     of points in the BLS Periodogram panel.
                                     Increasing the resolution will make the BLS Periodogram more accurate,
                                     but slower to render. To increase the resolution for a given peak,
                                     simply zoom in with the Box Zoom Tool.</span>

                                 </div>
                             </div>
                         """])
    return ColumnDataSource(data=data) 
开发者ID:KeplerGO,项目名称:lightkurve,代码行数:33,代码来源:interact_bls.py

示例8: prepare_f_help_source

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import ColumnDataSource [as 别名]
def prepare_f_help_source(f):
    data = dict(phase=[(np.max(f.time) - np.min(f.time)) * 0.98 + np.min(f.time)],
                flux=[(np.max(f.flux) - np.min(f.flux)) * 0.98 + np.min(f.flux)],
                helpme=['?'],
                help=["""
                        <div style="width: 375px;">
                            <div style="height: 190px;">
                            </div>
                            <div>
                                <span style="font-size: 12px; font-weight: bold;">Folded Light Curve</span>
                            </div>
                            <div>
                                <span style="font-size: 11px;"">This panel shows the folded light curve,
                                using the period currently selected in the BLS panel [left], indicated by the red line.
                                The transit model is show in red, and duration of the transit model
                                is given by the duration slider below. Update the slider to change the duration.
                                The period and transit midpoint values of the model are given above this panel.</span>
                                <br></br>
                                <span style="font-size: 11px;"">If the folded transit looks like a near miss of
                                the true period, try zooming in on the peak in the BLS Periodogram panel [right]
                                with the Box Zoom tool. This will increase the resolution of the peak, and provide
                                a better period solution. You can also vary the transit duration, for a better fit.
                                If the transit model is too shallow, it may be that you have selected a harmonic.
                                Look in the BLS Periodogram for a peak at (e.g. 0.25x, 0.5x, 2x, 4x the current period etc).</span>
                            </div>
                        </div>
                """])
    return ColumnDataSource(data=data) 
开发者ID:KeplerGO,项目名称:lightkurve,代码行数:30,代码来源:interact_bls.py

示例9: test_ylim_with_nans

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import ColumnDataSource [as 别名]
def test_ylim_with_nans():
    """Regression test for #679: y limits should not be NaN."""
    lc_source = ColumnDataSource({'flux': [-1, np.nan, 1]})
    ymin, ymax = get_lightcurve_y_limits(lc_source)
    # ymin/ymax used to return nan, make sure this is no longer the case
    assert ymin == -1.176
    assert ymax == 1.176 
开发者ID:KeplerGO,项目名称:lightkurve,代码行数:9,代码来源:test_interact.py

示例10: prepare_lightcurve_datasource

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import ColumnDataSource [as 别名]
def prepare_lightcurve_datasource(lc):
    """Prepare a bokeh ColumnDataSource object for tool tips.

    Parameters
    ----------
    lc : LightCurve object
        The light curve to be shown.

    Returns
    -------
    lc_source : bokeh.plotting.ColumnDataSource
    """
    # Convert time into human readable strings, breaks with NaN time
    # See https://github.com/KeplerGO/lightkurve/issues/116
    if (lc.time == lc.time).all():
        human_time = lc.time.isot
    else:
        human_time = [' '] * len(lc.flux)

    # Convert binary quality numbers into human readable strings
    qual_strings = []
    for bitmask in lc.quality:
        if isinstance(bitmask, u.Quantity):
            bitmask = bitmask.value
        flag_str_list = KeplerQualityFlags.decode(bitmask)
        if len(flag_str_list) == 0:
            qual_strings.append(' ')
        if len(flag_str_list) == 1:
            qual_strings.append(flag_str_list[0])
        if len(flag_str_list) > 1:
            qual_strings.append("; ".join(flag_str_list))

    lc_source = ColumnDataSource(data=dict(
                                 time=lc.time.value,
                                 time_iso=human_time,
                                 flux=lc.flux.value,
                                 cadence=lc.cadenceno.value,
                                 quality_code=lc.quality.value,
                                 quality=np.array(qual_strings)))
    return lc_source 
开发者ID:KeplerGO,项目名称:lightkurve,代码行数:42,代码来源:interact.py

示例11: update

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

    # Compute new y values: y
    y = np.sin(x) + np.random.random(N)

    # Update the ColumnDataSource data dictionary
    source.data = {'x': x, 'y': y}

# Add the update callback to the button 
开发者ID:qalhata,项目名称:Python-Scripts-Repo-on-Data-Science,代码行数:11,代码来源:DatVis_Bokeh_Intr_App_Build_4.py

示例12: plot_bokeh

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import ColumnDataSource [as 别名]
def plot_bokeh(df,sublist,filename):
    lenlist=[0]
    df_sub = df[df['cuisine']==sublist[0]]
    lenlist.append(df_sub.shape[0])
    for cuisine in sublist[1:]:
        temp = df[df['cuisine']==cuisine]
        df_sub = pd.concat([df_sub, temp],axis=0,ignore_index=True)
        lenlist.append(df_sub.shape[0])
    df_X = df_sub.drop(['cuisine','recipeName'],axis=1)
    print df_X.shape, lenlist

    dist = squareform(pdist(df_X, metric='cosine'))
    tsne = TSNE(metric='precomputed').fit_transform(dist)
    #cannot use seaborn palette for bokeh
    palette =['red','green','blue','yellow']
    colors =[]
    for i in range(len(sublist)):
        for j in range(lenlist[i+1]-lenlist[i]):
            colors.append(palette[i])
    #plot with boken
    output_file(filename)
    source = ColumnDataSource(
            data=dict(x=tsne[:,0],y=tsne[:,1],
                cuisine = df_sub['cuisine'],
                recipe = df_sub['recipeName']))

    hover = HoverTool(tooltips=[
                ("cuisine", "@cuisine"),
                ("recipe", "@recipe")])

    p = figure(plot_width=1000, plot_height=1000, tools=[hover],
               title="flavor clustering")

    p.circle('x', 'y', size=10, source=source,fill_color=colors)

    show(p) 
开发者ID:lingcheng99,项目名称:Flavor-Network,代码行数:38,代码来源:recipe_clustering.py

示例13: _scatter

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import ColumnDataSource [as 别名]
def _scatter(self, p, source, views, markers):
        """
        Parameters
        ----------
        p: bokeh.plotting.figure
            figure
        source: ColumnDataSource
            data container
        views: List[CDSView]
            list with views to be plotted (in order!)
        markers: List[str]
            corresponding markers to the views

        Returns
        -------
        scatter_handles: List[GlyphRenderer]
            glyph renderer per view
        """
        scatter_handles = []
        for view, marker in zip(views, markers):
            scatter_handles.append(p.scatter(x='x', y='y',
                                             source=source,
                                             view=view,
                                             color='color', line_color='black',
                                             size='size',
                                             marker=marker,
                                             ))
        return scatter_handles 
开发者ID:automl,项目名称:CAVE,代码行数:30,代码来源:configurator_footprint.py

示例14: jitterCurve

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import ColumnDataSource [as 别名]
def jitterCurve():
    output_file("PHmi_01.html")
    source=ColumnDataSource(data=dict(
        x=LandmarkMap_dic[1][0].tolist(),
        y=LandmarkMap_dic[1][1].tolist(),
        desc=[str(i) for i in list(range(LandmarkMap_dic[1][0].shape[0]))],
    ))
    TOOLTIPS=[
        ("index", "$index"),
        ("(x,y)", "($x, $y)"),
        ("desc", "@desc"),
    ]

    p=figure(plot_width=1800, plot_height=320, tooltips=TOOLTIPS,title="partition")
    p.circle('y','x',  size=5, source=source)
    p.line(PHMI_dic[0][1],PHMI_dic[0][0],line_color="coral", line_dash="dotdash", line_width=2)

    colors=('aliceblue', 'antiquewhite', 'aqua', 'aquamarine', 'azure', 'beige', 'bisque', 'black', 'blanchedalmond', 'blue', 'blueviolet', 'brown', 'burlywood', 'cadetblue', 'chartreuse', 'chocolate', 'coral', 'cornflowerblue', 'cornsilk', 'crimson', 'cyan', 'darkblue', 'darkcyan', 'darkgoldenrod', 'darkgray', 'darkgreen', 'darkgrey', 'darkkhaki', 'darkmagenta', 'darkolivegreen', 'darkorange', 'darkorchid', 'darkred', 'darksalmon', 'darkseagreen', 'darkslateblue', 'darkslategray', 'darkslategrey', 'darkturquoise', 'darkviolet', 'deeppink', 'deepskyblue', 'dimgray', 'dimgrey', 'dodgerblue', 'firebrick', 'floralwhite', 'forestgreen', 'fuchsia', 'gainsboro', 'ghostwhite', 'gold', 'goldenrod', 'gray', 'green', 'greenyellow', 'grey', 'honeydew', 'hotpink', 'indianred', 'indigo', 'ivory', 'khaki', 'lavender', 'lavenderblush', 'lawngreen', 'lemonchiffon', 'lightblue', 'lightcoral', 'lightcyan', 'lightgoldenrodyellow', 'lightgray', 'lightgreen', 'lightgrey', 'lightpink', 'lightsalmon', 'lightseagreen', 'lightskyblue', 'lightslategray', 'lightslategrey', 'lightsteelblue', 'lightyellow', 'lime', 'limegreen', 'linen', 'magenta', 'maroon', 'mediumaquamarine', 'mediumblue', 'mediumorchid', 'mediumpurple', 'mediumseagreen', 'mediumslateblue', 'mediumspringgreen', 'mediumturquoise', 'mediumvioletred', 'midnightblue', 'mintcream', 'mistyrose', 'moccasin', 'navajowhite', 'navy', 'oldlace', 'olive', 'olivedrab', 'orange', 'orangered', 'orchid', 'palegoldenrod', 'palegreen', 'paleturquoise', 'palevioletred', 'papayawhip', 'peachpuff', 'peru', 'pink', 'plum', 'powderblue', 'purple', 'red', 'rosybrown', 'royalblue', 'saddlebrown', 'salmon', 'sandybrown', 'seagreen', 'seashell', 'sienna', 'silver', 'skyblue', 'slateblue', 'slategray', 'slategrey', 'snow', 'springgreen', 'steelblue', 'tan', 'teal', 'thistle', 'tomato', 'turquoise', 'violet', 'wheat', 'white', 'whitesmoke', 'yellow', 'yellowgreen')
    ScalePhmi=math.pow(10,1)
    i=0
    for val,idx in zip(phmi_breakPtsNeg, plot_x):
        p.line(idx,np.array(val)*ScalePhmi,line_color=colors[i])
        i+=1

    show(p)

#05-network show between PHMI and landmarks 网络分析
#extract landmarks corresponding to the AVs' position along a route 
开发者ID:richieBao,项目名称:python-urbanPlanning,代码行数:30,代码来源:showMatLabFig._spatioTemporal.py

示例15: jitterCurve

# 需要导入模块: from bokeh import plotting [as 别名]
# 或者: from bokeh.plotting import ColumnDataSource [as 别名]
def jitterCurve(phmi_breakPtsNeg,landmarks_coordi,PHMI_coordi,plot_x): #LandmarkMap_dic,PHMI_dic
    output_file("PHmi_01.html")
    source=ColumnDataSource(data=dict(
        x=landmarks_coordi[0].tolist(),
        y=landmarks_coordi[1].tolist(),
        desc=[str(i) for i in list(range(landmarks_coordi[0].shape[0]))],
    ))
    TOOLTIPS=[
        ("index", "$index"),
        ("(x,y)", "($x, $y)"),
        ("desc", "@desc"),
    ]

    p=figure(plot_width=1800, plot_height=320, tooltips=TOOLTIPS,title="partition")
    p.circle('y','x',  size=5, source=source)
    p.line(PHMI_coordi[1],PHMI_coordi[0],line_color="coral", line_dash="dotdash", line_width=2)

    colors=('aliceblue', 'antiquewhite', 'aqua', 'aquamarine', 'azure', 'beige', 'bisque', 'black', 'blanchedalmond', 'blue', 'blueviolet', 'brown', 'burlywood', 'cadetblue', 'chartreuse', 'chocolate', 'coral', 'cornflowerblue', 'cornsilk', 'crimson', 'cyan', 'darkblue', 'darkcyan', 'darkgoldenrod', 'darkgray', 'darkgreen', 'darkgrey', 'darkkhaki', 'darkmagenta', 'darkolivegreen', 'darkorange', 'darkorchid', 'darkred', 'darksalmon', 'darkseagreen', 'darkslateblue', 'darkslategray', 'darkslategrey', 'darkturquoise', 'darkviolet', 'deeppink', 'deepskyblue', 'dimgray', 'dimgrey', 'dodgerblue', 'firebrick', 'floralwhite', 'forestgreen', 'fuchsia', 'gainsboro', 'ghostwhite', 'gold', 'goldenrod', 'gray', 'green', 'greenyellow', 'grey', 'honeydew', 'hotpink', 'indianred', 'indigo', 'ivory', 'khaki', 'lavender', 'lavenderblush', 'lawngreen', 'lemonchiffon', 'lightblue', 'lightcoral', 'lightcyan', 'lightgoldenrodyellow', 'lightgray', 'lightgreen', 'lightgrey', 'lightpink', 'lightsalmon', 'lightseagreen', 'lightskyblue', 'lightslategray', 'lightslategrey', 'lightsteelblue', 'lightyellow', 'lime', 'limegreen', 'linen', 'magenta', 'maroon', 'mediumaquamarine', 'mediumblue', 'mediumorchid', 'mediumpurple', 'mediumseagreen', 'mediumslateblue', 'mediumspringgreen', 'mediumturquoise', 'mediumvioletred', 'midnightblue', 'mintcream', 'mistyrose', 'moccasin', 'navajowhite', 'navy', 'oldlace', 'olive', 'olivedrab', 'orange', 'orangered', 'orchid', 'palegoldenrod', 'palegreen', 'paleturquoise', 'palevioletred', 'papayawhip', 'peachpuff', 'peru', 'pink', 'plum', 'powderblue', 'purple', 'red', 'rosybrown', 'royalblue', 'saddlebrown', 'salmon', 'sandybrown', 'seagreen', 'seashell', 'sienna', 'silver', 'skyblue', 'slateblue', 'slategray', 'slategrey', 'snow', 'springgreen', 'steelblue', 'tan', 'teal', 'thistle', 'tomato', 'turquoise', 'violet', 'wheat', 'white', 'whitesmoke', 'yellow', 'yellowgreen')
    colors=colors*5
    ScalePhmi=math.pow(10,1)
    i=0
    for val,idx in zip(phmi_breakPtsNeg, plot_x):
        p.line(idx,np.array(val)*ScalePhmi,line_color=colors[i])
        i+=1

    show(p)

#04-network show between PHMI and landmarks 网络分析
#extract landmarks corresponding to the AVs' position along a route 
开发者ID:richieBao,项目名称:python-urbanPlanning,代码行数:31,代码来源:driverlessCityProject_spatialPointsPattern_association_basic.py


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