Hi All
This is the first of a series of question about rendering GMap along with tab panes (and slider to come).
The GMap, when plotted by itself or as a single tab pane, works perfectly. However, when multiple plots are issued, here’s what happens:
-
first tab shows the map, but no data
-
subsequent tabs show blank
Ideally, I’ll eventually get to using a slider to control what is shown…, but the tab panes will more than suffice for now. Any idea what is causing this?
Any help is much appreciated!!!
SH
df_theft_auto.csv.zip (195 KB)
···
#Here is the code.
from future import print_function
from bokeh.document import Document
from bokeh.embed import file_html
from bokeh.models.glyphs import Circle
from bokeh.models import (
GMapPlot, Range1d, ColumnDataSource,
PanTool, WheelZoomTool, BoxSelectTool,
GMapOptions)
from bokeh.resources import INLINE
from bokeh.plotting import show, output_notebook
#from bokeh.util.browser import view
from bokeh.models.widgets import Panel, Tabs
from bokeh.palettes import Spectral7
map_options = GMapOptions(
lat=37.763, lng=-122.444,
map_type=“roadmap”,
zoom=13,
styles="""
[{“featureType”:“administrative”,“elementType”:“all”,“stylers”:[{“visibility”:“on”},{“lightness”:33}]},{“featureType”:“landscape”,“elementType”:“all”,“stylers”:[{“color”:"#f2e5d4"}]},{“featureType”:“poi.park”,“elementType”:“geometry”,“stylers”:[{“color”:"#c5dac6"}]},{“featureType”:“poi.park”,“elementType”:“labels”,“stylers”:[{“visibility”:“on”},{“lightness”:20}]},{“featureType”:“road”,“elementType”:“all”,“stylers”:[{“lightness”:20}]},{“featureType”:“road.highway”,“elementType”:“geometry”,“stylers”:[{“color”:"#c5c6c6"}]},{“featureType”:“road.arterial”,“elementType”:“geometry”,“stylers”:[{“color”:"#e4d7c6"}]},{“featureType”:“road.local”,“elementType”:“geometry”,“stylers”:[{“color”:"#fbfaf7"}]},{“featureType”:“water”,“elementType”:“all”,“stylers”:[{“visibility”:“on”},{“color”:"#acbcc9"}]}]
“”")
x_range = Range1d()
y_range = Range1d()
i=0
Data source
day = “Sunday”
temp = theft_auto[theft_auto[‘DayOfWeek’] == day]
source = ColumnDataSource(data=dict(lat=temp[‘Y’], lon=temp[‘X’]))
Setup GMapPlot
plot0 = GMapPlot(
x_range=x_range, y_range=y_range,
map_options=map_options,
title="Car Break-ins on "+day+‘s’, plot_width=1000, plot_height=900
)
Setup glyph
circle = Circle(x=“lon”, y=“lat”, size=3, fill_color=Spectral7[i], line_color=Spectral7[i])
Combine data with glyph for the plot
plot0.add_glyph(source, circle)
Add to designated tab
tab0 = Panel(child=plot0, title=day)
i=i+1
Data source
day = “Monday”
temp = theft_auto[theft_auto[‘DayOfWeek’] == day]
source = ColumnDataSource(data=dict(lat=temp[‘Y’], lon=temp[‘X’]))
Setup GMapPlot
plot1 = GMapPlot(
x_range=x_range, y_range=y_range,
map_options=map_options,
title="Car Break-ins on "+day+‘s’, plot_width=1000, plot_height=900
)
Setup glyph
circle = Circle(x=“lon”, y=“lat”, size=3, fill_color=Spectral7[i], line_color=Spectral7[i])
Combine data with glyph for the plot
plot1.add_glyph(source, circle)
Add to designated tab
tab1 = Panel(child=plot1, title=day)
tabs = Tabs(tabs=[ tab0, tab1 ])
pan = PanTool()
wheel_zoom = WheelZoomTool()
plot.add_tools(pan, wheel_zoom)
show(tabs)