地理视图点:使用高和低选项更改色彩映射

时间:2018-03-06 15:17:53

标签: bokeh holoviews

我最近看了this question关于手动设置全息视图颜色条的限制,但是在更改了我的某个视图之后的范围后,它并没有改变颜色条的上限和下限。有没有办法直接为特定的vdim传递Bokeh LinearColorMapper(及其选项)?

opts = {'plot' : dict(width=width_val, height=height_val, tools=[hover_shipments],
                  size_index='po_qty', 
                  color_index='magnitude',
                  size_fn=(lambda x : x/100),
                  click_policy='hide', colorbar=True),
   'style': dict(cmap='Viridis', line_width=0.25, alpha=0.75, fill_alpha=0.75,
                muted_alpha=0.05)}

ds_time_store.to(gv.Points, 
                      kdims=['longitude_qty','latitude_qty'], 
                      vdims=['store_num', 
                             'city_nm', 
                             'po_qty', 
                             hv.Dimension('magnitude', range=(0, 50))], label='late').opts({'Points' : opts})

1 个答案:

答案 0 :(得分:0)

在设置点数之前,通过在我的数据集redim(aggregate_rating=dict(range=(0, 5)))上调用locality_ratings,我可以根据我的评分将颜色栏的边界设置为0到5。

    points = locality_ratings.redim(aggregate_rating=dict(range=(0, 5))).to(gv.Points, ['longitude', 'latitude'], 
                ['aggregate_rating', 'votes', 'cuisine_count', 'average_cost_for_two', 'price_range', 'locality'])
    (gts.Wikipedia * points.options(width=700, height=600, 
                            tools=['hover', 'save', 'zoom_in', 'zoom_out', 'pan' , 'wheel_zoom'],
                            colorbar=True, toolbar='above', xaxis=None, yaxis=None,
                            size_index=3, color_index=2, size=3, cmap=bokeh.palettes.all_palettes['Dark2'][5])).redim(longitude="Longitude",
                                                                                            latitude="Latitude",
                                                                                            aggregate_rating='Rating', 
                                                                                            locality="Locality",
                                                                                           votes="Votes",
                                                                                           price_range="Price Range",
                                                                                           average_cost_for_two="Avg. Cost for 2 (R)",
                                                                                           cuisine_count="No. Cuisines"
                                                                                        )