Hi there,
I modified the geoJSON world map data and added a layer of numbers from a subset of countries and assign colors according to this value. I got the map working, however, the color is a little off. Note I assign the number to be 0 except 5 countries: Austria, China, Indonesia, Japan and Russia. I expect to see different colors only for these regions. However, I observe color changes in a few other places, like Australia, Argentina, US and Canada etc, which clearly has the number right (=0), but colors wrong. Do you have any idea what’s causing this issue? Thanks!
Here’s my code:
from bokeh.io import show, output_notebook, output_file
from bokeh.models import (
GeoJSONDataSource,
HoverTool,
LinearColorMapper
)
from bokeh.plotting import figure
from bokeh.palettes import Viridis6
from collections import OrderedDict
with open(r'countries.geo.count.json', 'r') as f:
geo_source = GeoJSONDataSource(geojson=f.read())
color_mapper = LinearColorMapper(palette=Viridis6)
TOOLS = "pan,wheel_zoom,box_zoom,reset,hover,save"
## full canvas of world countries
p = figure(
width = 800 , height=400 , title='World Countries' , tools =TOOLS,
x_axis_label='Longitude' ,
y_axis_label='Latitude'
<a class='attachment' href='//bokeh-discourse-uploads.s3.dualstack.us-east-1.amazonaws.com/original/1X/6a809f048f24deb7abe60e466dcfc47c817e6030.json'>countries.geo.count.json</a> (275 KB)
<a class='attachment' href='//bokeh-discourse-uploads.s3.dualstack.us-east-1.amazonaws.com/original/1X/97f8494a27babffb323a8f9238327ea89a6bdfd6.html'>dist.html</a> (1.68 MB)
<details class='elided'>
<summary title='Show trimmed content'>···</summary>
,
)
p.grid.grid_line_color = None
p.patches('xs', 'ys', fill_alpha=0.7, fill_color={'field': 'num', 'transform' : color_mapper}, line_color='white', line_width=0.5
, source=geo_source)
hover = p.select(dict(type=HoverTool))
hover.point_policy = "follow_mouse"
hover.tooltips = OrderedDict([
("Name", "@name" ),
("umber", "@num" ),
("(Long, Lat)", "($x, $y)"
),
])
output_file("dist.html", title="Worldwide distribution"
)
show(p)