0

我是新来的。我想知道改变点的外观pandas_bokeh或其他库的外观允许使用地图创建仪表板的可能性(我在 SVG 中有一个图标)。我想更改变量的图标my_hover.tooltips = [('SIEC', '@siec')]

我尝试hovertool_string在图表上运行 Bokeh。但是我不知道,如何在地图上更改它。

这是我想要的例子

from bokeh.plotting import figure, show, output_file
from bokeh.tile_providers import CARTODBPOSITRON
from bokeh.io import show, output_file
from bokeh.models import Plot, Range1d, MultiLine, Circle, HoverTool, TapTool, BoxSelectTool
from bokeh.models.graphs import from_networkx, NodesAndLinkedEdges, EdgesAndLinkedNodes
from bokeh.palettes import Spectral4
from bokeh.models import ColumnDataSource, CDSView, GroupFilter

palette = itertools.cycle(sns.color_palette())
colors = itertools.cycle(palette) 

lista_kolorow = [
"#000000", "#FFFF00", "#1CE6FF", "#FF34FF", "#FF4A46", "#008941", "#006FA6", "#A30059",
"#FFDBE5", "#7A4900", "#0000A6", "#63FFAC", "#B79762", "#004D43", "#8FB0FF", "#997D87",
"#5A0007", "#809693", "#FEFFE6", "#1B4400", "#4FC601", "#3B5DFF", "#4A3B53", "#FF2F80",
"#61615A", "#BA0900", "#6B7900", "#00C2A0", "#FFAA92", "#FF90C9", "#B903AA", "#D16100",
"#DDEFFF", "#000035", "#7B4F4B", "#A1C299", "#300018", "#0AA6D8", "#013349", "#00846F",
"#372101", "#FFB500", "#C2FFED", "#A079BF", "#CC0744", "#C0B9B2", "#C2FF99", "#001E09",
"#00489C", "#6F0062", "#0CBD66", "#EEC3FF", "#456D75", "#B77B68", "#7A87A1", "#788D66",
"#885578", "#FAD09F", "#FF8A9A", "#D157A0", "#BEC459", "#456648", "#0086ED", "#886F4C",
"#34362D", "#B4A8BD", "#00A6AA", "#452C2C", "#636375", "#A3C8C9", "#FF913F", "#938A81",
"#575329", "#00FECF", "#B05B6F", "#8CD0FF", "#3B9700", "#04F757", "#C8A1A1", "#1E6E00",
"#7900D7", "#A77500", "#6367A9", "#A05837", "#6B002C", "#772600", "#D790FF", "#9B9700",
"#549E79", "#FFF69F", "#201625", "#72418F", "#BC23FF", "#99ADC0", "#3A2465", "#922329",
"#5B4534", "#FDE8DC", "#404E55", "#0089A3", "#CB7E98", "#A4E804", "#324E72", "#6A3A4C"
]

## tworzenie mapy 
output_file("tile.html")

source = ColumnDataSource(
        data=dict(lat=result['LATITUDE'].tolist(),
                  lon=result['LONGITUDE'].tolist(),
                  merkor_x=result['merkor_x'].tolist(),
                  merkor_y=result['merkor_y'].tolist(),
                  siec=result['SIEC'].tolist(),
                  adres=result['ADRES_CZYSTY'].tolist()))

dict_source = {}
for i in np.arange(0,len(result['SIEC'].unique())):
    dict_source["source_" + result['SIEC'].unique()[i]] = ColumnDataSource(
                            data=dict(lat=result[result["SIEC"]== result['SIEC'].unique()[i]]['LATITUDE'].tolist(),
                                      lon=result[result["SIEC"]== result['SIEC'].unique()[i]]['LONGITUDE'].tolist(),
                                      merkor_x=result[result["SIEC"]== result['SIEC'].unique()[i]]['merkor_x'].tolist(),
                                      merkor_y=result[result["SIEC"]== result['SIEC'].unique()[i]]['merkor_y'].tolist(),
                                      siec=result[result["SIEC"]== result['SIEC'].unique()[i]]['SIEC'].tolist(),
                                      adres=result[result["SIEC"]== result['SIEC'].unique()[i]]['ADRES_CZYSTY'].tolist()))


dict_view = {}
for i in np.arange(0,len(result['SIEC'].unique())):
    dict_view[result['SIEC'].unique()[i]+ '_view'] = CDSView(source=list(dict_source.values())[i])

common_figure_kwargs = {
    'plot_width': 1800,
    'plot_height' : 1500,
    'x_axis_label': 'Points'
}

dict_common_circle_kwargs = {}
for i in np.arange(0,len(result['SIEC'].unique())):
    dict_common_circle_kwargs["common_circle_kwargs_" + result['SIEC'].unique()[i]] = {
                                                                                    'x': 'merkor_x',
                                                                                    'y': 'merkor_y',
                                                                                    'source': list(dict_source.values())[i],
                                                                                    'size': 3,
                                                                                    'alpha': 0.7}

dict_common_shop_kwargs = {}
for i in np.arange(0,len(result['SIEC'].unique())):
    dict_common_shop_kwargs["common_" + result['SIEC'].unique()[i] +"_kwargs"] =  {
                                                                                    'view': list(dict_view.values())[i],
                                                                                    'color': lista_kolorow[i],
                                                                                    'legend': result['SIEC'].unique()[i]}


mapa = figure(**common_figure_kwargs, x_range=(1558321.476598351, 2694056.6889853813), y_range=(6274531.544317098, 7331682.201156591),
           x_axis_type="mercator", y_axis_type="mercator")
mapa.add_tile(CARTODBPOSITRON)

for i in np.arange(0,len(result['SIEC'].unique())):
        mapa.circle(**list(dict_common_circle_kwargs.values())[i], **list(dict_common_shop_kwargs.values())[i])



mapa.legend.click_policy = 'hide'
mapa.xaxis.axis_label = 'SZEROKOSC'
mapa.yaxis.axis_label = 'DLUGOSC'
mapa.legend.location = "top_left"


my_hover = HoverTool()
my_hover.tooltips = [('SIEC', '@siec'),
                     ('SZEROKOŚĆ', '@lat'),
                     ('DŁUGOŚĆ', '@lon'),
                     ('ADRES', '@adres')]
mapa.add_tools(my_hover)

我没有任何错误消息,我只是不知道该怎么做......

4

1 回答 1

0

如果你想用图像替换地图上的点,你可以image_url像在这个例子中那样使用(解决方案是针对 Bokeh v1.1.0,因为首先我不清楚你的目标是pandas_bokeh)。要固定图像的大小,请使用h_units = 'screen', w_units = 'screen'

from bokeh.plotting import figure, show

p = figure(name = 'Doggys', x_range = (2, 18), y_range = (-10, 10))
p.image_url(url = ['https://cdn3.iconfinder.com/data/icons/line/36/dog_head-512.png'], x = [10], y = [0], w = [50], h = [50], h_units = 'screen', w_units = 'screen')
p.image_url(url = ['https://cdn3.iconfinder.com/data/icons/dogs-outline/100/dog-02-512.png'], x = [5], y = [5], w = [50], h = [50], h_units = 'screen', w_units = 'screen')


show(p)

在此处输入图像描述

于 2019-05-17T13:11:28.067 回答