2017-11-30 11 views
0

질문 업데이트 :bokeh의 vbar는 비 선택 색상 및 알파를 지원하지 않습니까?

바 plot에서 특정 종을 선택하는 방법, 선택되지 않은 막대는 색상이 변경됩니까? 각 막대 위에 텍스트를 표시하는 방법은 무엇입니까?

from bokeh.sampledata.iris import flowers 
from bokeh.plotting import figure, output_file, show 
from bokeh.models import ColumnDataSource, CategoricalColorMapper 
from bokeh.layouts import column, row 

#color mapper to color data by species 
mapper = CategoricalColorMapper(factors = ['setosa','versicolor', 'virginica'],\ 
           palette = ['green', 'blue', 'red']) 


output_file("plots.html") 

#group by species and plot barplot for count 
species = flowers.groupby('species') 

source = ColumnDataSource(species) 

p = figure(plot_width = 800, plot_height = 400, title = 'Count by Species', \ 
      x_range = source.data['species'], tools = 'box_select') 

p.vbar(x = 'species', top = 'petal_length_count', width = 0.8, source = source,\ 
     nonselection_fill_color = 'gray', nonselection_fill_alpha = 0.2,\ 
     color = {'field': 'species', 'transform': mapper}) 
show(p) 

답변

2

먼저 서로 다른 관련 게시물에 질문 해보십시오.


히트 테스트와 선택은 최근까지 vbarhbar 구현되지 않았습니다. 당신이 원하는대로 최근 0.12.11 릴리스를 사용하여, 코드가 동작 : 각 막대의 레이블에 대해서는

enter image description here

, 당신은 LabelSet 주석을 사용하려면, 같은 demonstrated in the User's Guide 뭔가 같이

labels = LabelSet(x='species', y='petal_count_length', text='some_column', 
        x_offset=5, y_offset=5, source=source) 

p.add_layout(labels) 

링크 질문이 너무 애매합니다. 나는 당신이 정확히 무엇을 성취하려고하는지 더 많은 정보와 설명으로 새로운 질문을 열 것을 제안합니다.

+0

답변 해 주셔서 감사합니다. 그것은 처음 두 가지 질문을 해결하고 해결합니다. 귀하의 제안으로 코드를 업데이트하고 링크 된 그래프에 대한 별도의 질문을 여기에서 요청하십시오. https://stackoverflow.com/questions/47579840/how-to-link-vbar-with-circle-plots-using-bokeh –