我正在尝试在bokeh中的gmap上绘制多边形。如果我生成一个空白图并像上面那样添加数据,
tractfigure = figure(title = "Share of tract population that are beyond 1 mile from supermarket, Travis County",
plot_height = 600, plot_width = 600,
toolbar_location = "right",
tools = "pan,wheel_zoom")
tractfigure.xgrid.grid_line_color = None
tractfigure.ygrid.grid_line_color = None
tractfigure.patches('xs','ys', source = data_source,fill_color = {'field' :'plotted_data', 'transform' : color_mapper},
line_color = 'black', line_width = 0.25, fill_alpha = 1)
它将根据绘制的数据字段生成具有多个具有不同颜色的多边形的图形。 GmapPlot对象没有补丁功能,因此我尝试使用add_glyph函数添加补丁。
plot = GMapPlot(x_range = Range1d(),
y_range = Range1d(),
map_options = map_options,
plot_width = 600,
plot_height = 600)
plot.api_key = "secret"
patch = Patches(xs = 'x', ys = 'y',
fill_color = {"field": 'plotted_data', "transform": color_mapper},
fill_alpha = 0.7, line_color = "black", line_width = 1)
plot.add_glyph(data_source, patch)
这会编译,但bokeh会生成一个空对象。如何在gmapplot上映射GeoJSONDataSource?