预先感谢您的帮助。
我正在使用Bokeh在区域级别绘制英国地图,并用目标变量对不同颜色填充的区域进行分级(根据级别从绿色到红色)。
我想在地图上绘制区域的名称(存储在名为nuts1_label的变量中),但是我无法做到。 我能够创建一个悬停,但是只有在交互式版本中才可见,而我需要永久显示区域的名称。
我在这里绘制代码:
g_var = 'target_var'
#Define color palette.
palette = col_map
#Instantiate LinearColorMapper that linearly maps numbers in a range, into a sequence of colors.
color_mapper = LinearColorMapper(palette = palette, low = merged[g_var].min(), high = merged[g_var].max(), nan_color = '#d9d9d9')
#Create color bar.
color_bar = ColorBar(color_mapper=color_mapper, label_standoff=10,width = 500, height = 20,
border_line_color=None,location = (0,0), orientation = 'horizontal')
#Create figure object.
p = figure(title = 'Title',
plot_height = 700 , plot_width = 500, toolbar_location = None, tools = [hover])
p.xgrid.grid_line_color = None
p.ygrid.grid_line_color = None
p.axis.visible = False
p.title.text_font_size = '8pt'
#Add patch renderer to figure.
p.patches('xs','ys', source = geosource, fill_color = {'field' : g_var, 'transform' : color_mapper},
line_color = 'black', line_width = 0.25, fill_alpha = 1)
#Specify figure layout and hover
p.add_layout(color_bar, 'below')
hover = HoverTool(tooltips = [ ('Region','@nuts1_label')])
#Display figure inline in Jupyter Notebook.
output_notebook()
export_png(p, filename="F1.png")
show(p)
再次感谢您的帮助。 安德里亚