Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用套索绘制博克数据的选择_Python_Jupyter Notebook_Bokeh - Fatal编程技术网

Python 使用套索绘制博克数据的选择

Python 使用套索绘制博克数据的选择,python,jupyter-notebook,bokeh,Python,Jupyter Notebook,Bokeh,我有一些数据,我一直在和博克一起绘制。这是一些多方面学习分析的结果,深入到两个维度。我想做的是使用lasso工具选择数据点的一部分,然后绘制这些数据点的一个特定特征的直方图 使用此帖子: 还有这个 我了解到,你可以在选择后获得索引,也可以绘制数据相互链接的图。我可以使用这些索引选择数据点的子集,其中有一个我感兴趣的特性。但是,我希望能够简化这个过程。当我做套索选择时,我想要另一个图来生成所选索引的直方图。我的问题是如何处理回调。我似乎无法确定正确的顺序,我似乎也不知道如何将这些情节相互联系起

我有一些数据,我一直在和博克一起绘制。这是一些多方面学习分析的结果,深入到两个维度。我想做的是使用lasso工具选择数据点的一部分,然后绘制这些数据点的一个特定特征的直方图

使用此帖子:

还有这个

我了解到,你可以在选择后获得索引,也可以绘制数据相互链接的图。我可以使用这些索引选择数据点的子集,其中有一个我感兴趣的特性。但是,我希望能够简化这个过程。当我做套索选择时,我想要另一个图来生成所选索引的直方图。我的问题是如何处理回调。我似乎无法确定正确的顺序,我似乎也不知道如何将这些情节相互联系起来

x = range(0, len(x_toPlot[:,0]))
y0 = x_toPlot[:,0]
y1 = x_toPlot[:,1]

# create a column data source for the plots to share
source = ColumnDataSource(data=dict(x=x, y0=y0, y1=y1))
testSource= ColumnDataSource(data=dict(x=x, y0=y0))

TOOLS = "lasso_select,help"

# create a new plot and add a renderer
left = figure(tools=TOOLS, width=300, height=300, title=None)
left.circle('y0', 'y1', source=source)

# create another new plot and add a renderer
middle = figure(tools=TOOLS, width=300, height=300, title=None)
middle.circle('x', 'y1', source=source)


right = figure(tools=TOOLS, width=300, height=300, title=None)
right.circle('x','y0', source=testSource)

p = gridplot([[left, middle]])


#create a function aboeve.. and then call that funciton in here...
source.callback = CustomJS(args=dict(p=p), code="""
        var inds = cb_obj.get('selected')['1d'].indices;
        var d1 = cb_obj.get('data');
        console.log(d1)
        var kernel = IPython.notebook.kernel;
        IPython.notebook.kernel.execute("inds = " + inds);
        IPython.notebook.kernel.execute("updateInds(inds)");


        IPython.notebook.kernel.execute("res=X['education_num']");
        IPython.notebook.kernel.execute("res=res.loc[inds2]");        
        IPython.notebook.kernel.execute("testSource= ColumnDataSource(data=dict(x=inds2, y0=res))");
        IPython.notebook.kernel.execute("right = figure(tools=TOOLS, width=300, height=300, title=None)");
        IPython.notebook.kernel.execute("right.circle('x','y0', source=testSource)");
        IPython.notebook.kernel.execute("p2 = gridplot([[ right]])");        
        IPython.notebook.kernel.execute("push_notebook(p2)");


        """
)
还有另外一个我试图调用的函数,叫做updateInds,它会在我使用lasso选择时更新索引

def updateInds(f):
    global inds2
    inds2=list(f)
    print ("hello")
    global testingThing
    testingThing=zip([source.data['x'][i] for i in inds],    [source.data['y0'][i] for i in inds])
    push_notebook()

我在Jupyter笔记本电脑环境中工作。

我建议尝试改编此示例:我建议尝试改编此示例: