2016-10-03 7 views
0

私はbokeh 0.12.2を使用しています。私は言葉で選択している。単語を選択すると、ドットデータが丸くなります。それはその後動作を停止するようです。私は2つの単語、word1とword2を試しています。 lastidxはindex.xcで満ちていて、yxはここの円の位置です。これは、1つの作業ですが、私は選択の値を変更しないで本当に場合:bokehで選択して実際には動作しません

  for j in range(0,2): 
       for i in range(0,len(lastidx[j])): 
        xc.append(tsne_kmeans[lastidx[j][i], 0]) 
        yc.append(tsne_kmeans[lastidx[j][i], 1]) 

     source = ColumnDataSource(data=dict(x=xc, y=yc, s=mstwrd)) 

     def callback(source=source): 
      dat = source.get('data') 
      x, y, s = dat['x'], dat['y'], dat['s'] 

      val = cb_obj.get('value') 

      if val == 'word1': 
       for i in range(0,75): 
        x[i] = x[i] 
        y[i] = y[i] 
      elif val == 'word2': 
       for i in range(76,173): 
        x[i-76] = x[i] 
        y[i-76] = y[i] 

      source.trigger('change') 

     slct = Select(title="Word:", value="word1", options=mstwrd , callback=CustomJS.from_py_func(callback)) 



     # create the circle around the data where the word exist 
     r = plot_kmeans.circle('x','y', source=source) 


     glyph = r.glyph 
     glyph.size = 15 
     glyph.fill_alpha = 0.0 
     glyph.line_color = "black" 
     glyph.line_dash = [4, 2] 
     glyph.line_width = 1 

xとyはここにすべてのデータがロードされていると私はちょうど私が選択する単語のデータを選択します。それはうまくいくように見えますが、そうではありません。 find word

スタンドアロンチャートとしても可能ですか? ありがとうございました

答えて

0

私はそれを理解しました:ここでのコードは、これが機能しているかどうかを確認することです。もちろんこれは改善されるでしょう。そして、これが最後にここに書かれたものであることがあります私は行列を渡すことができれば https://github.com/bokeh/bokeh/issues/2618

for i in range(0,len(lastidx[0])): 
       xc.append(tsne_kmeans[lastidx[0][i], 0]) 
       yc.append(tsne_kmeans[lastidx[0][i], 1]) 
      addto = len(lastidx[1])-len(lastidx[0]) 
      # here i max out the data which has the least 
      # so when you go from one option to the other it 
      # removes all the previous data circle 
      for i in range(0,addto): 
       xc.append(-16) # just send them somewhere 
       yc.append(16) 
      for i in range(0, len(lastidx[1])): 
       xf.append(tsne_kmeans[lastidx[1][i], 0]) 
       yf.append(tsne_kmeans[lastidx[1][i], 1]) 
     x = xc 
     y = yc 
     source = ColumnDataSource(data=dict(x=x, y=y,xc=xc,yc=yc,xf=xf,yf=yf)) 

     val = "word1" 
     def callback(source=source): 
      dat = source.get('data') 
      x, y,xc,yc,xf,yf = dat['x'], dat['y'], dat['xc'], dat['yc'], dat['xf'], dat['yf'] 
      # if slct.options['value'] == 'growth': 
      val = cb_obj.get('value') 

      if val == 'word1': 
       for i in range(0,len(xc)): 
        x[i] = xc[i] 
        y[i] = yc[i] 
      elif val == 'word2': 
       for i in range(0,len(xf)): 
        x[i] = xf[i] 
        y[i] = yf[i] 

      source.trigger('change') 

     slct = Select(title="Most Used Word:", value=val, options=mstwrd , callback=CustomJS.from_py_func(callback)) 



     # create the circle around the data where the word exist 
     r = plot_kmeans.circle('x','y', source=source) 

私がチェックします。同じサイズのデータ​​を持つことを忘れないでください。複数のオプションが同時に表示されない場合は、 ありがとうございました

関連する問題