Reputation: 65
I was trying to plot the rate of trips/day for particular subway stop. I tried plotting it using bokeh. When I am using bokeh sample data it is working fine but, when I am passing data for which I have to plot a bokeh It displays me blank bokeh plot.
I am using below code:
from bokeh.io import show
from bokeh.models import (
ColumnDataSource,
HoverTool,
LogColorMapper
)
from bokeh.palettes import Viridis6 as palette
from bokeh.plotting import figure
palette.reverse()
county_xs = stop_frame['latitude'].tolist()
county_ys = stop_frame['longitude'].tolist()
county_names = stop_frame['stop_name'].tolist()
county_rates = stop_frame['Rate'].tolist()
color_mapper = LogColorMapper(palette=palette)
source = ColumnDataSource(data=dict(
x=county_xs,
y=county_ys,
name=county_names,
rate=county_rates,
))
TOOLS = "pan,wheel_zoom,reset,hover,save"
p = figure(
title="Busy Stops of MBTA", tools=TOOLS,
x_axis_location=None, y_axis_location=None
)
p.grid.grid_line_color = 'Red'
p.patches('x', 'y', source=source,
fill_color={'field': 'rate', 'transform': color_mapper},
fill_alpha=0.7, line_color="black", line_width=0.5)
hover = p.select_one(HoverTool)
hover.point_policy = "follow_mouse"
hover.tooltips = [
("Stop Name", "@name"),
("Number", "@rate%"),
("(Long, Lat)", "($x, $y)"),
]
show(p)
This is the plot I gotI want plot like this
I am using below data for the plot:
List of Latitude:
[42.3743352, 42.405219, 42.3487121, 42.3300161, 42.3596754, 42.351771, 42.2834319, 42.360653, 42.3528916, 42.3507067, 42.3307916, 42.3833663, 42.3384306, 42.3492202, 42.33540795, 42.350082, 42.349733, 42.3508198, 42.3613995, 42.3529947, 42.356282, 42.137775, 42.334317, 42.3432487, 42.3105415, 42.3373934, 14.8378415, 42.3611931, 42.9395288, 42.3383404, 42.352444, 42.3405937, 42.3362324, 42.3324596, 42.35215405, 42.3500312, 42.2814234, 42.334912, 42.3551473, 42.32992935, 42.3379418, 42.350675, 42.343451, 42.3340172, 42.3000984, nan, 42.3594924, 42.310412, 42.3487386, 42.36782045, 42.3502301, 42.3578153, 42.3621468, 42.3264153, 42.34712945, nan, nan, 42.322592, nan, 42.3489672, 42.3767055, 42.3683325, 42.336163, 42.336163, 42.3401342, 42.3490087, 42.3691041, 42.3331908, 42.3379387, 42.34315285, 42.33540795, 42.2818516, 42.3652935, 42.3400618, 36.77198965, 42.3912083, 42.3517318, 42.298263, 42.312474, 42.374924, 42.345596, nan, 42.2462086, 42.33511665, 42.400464, 52.985536, 42.3385722, 42.3306533, 42.3366072, nan, 42.3511128, 42.3106539, 42.3667045, 42.293126, 42.35184265, 42.3398175, 42.3588444, 42.317224, 42.39051, 42.3843509, 42.344126, 42.3399846, 42.3426644, 42.289375, 42.3496554, 42.3103337, 42.3484028, 34.1472316, 42.3440373, -41.2932518, 42.2868127, 42.935891, 42.3796991, 42.17368655, 42.3743352, 42.405219, 42.3487121, 42.3300161, 42.3596754, 42.351771, 42.2834319, 42.360653, 42.3528916, 42.3507067, 42.3307916, 42.3833663, 42.3384306, 42.3492202, 42.33540795, 42.350082, 42.349733, 42.3508198, 42.3613995, 42.3529947, 42.356282, 42.137775, 42.334317, 42.3432487, 42.3105415, 42.3373934, 14.8378415, 42.3611931, 42.9395288, 42.3383404, 42.352444, 42.3405937, 42.3362324, 42.3324596, 42.35215405, 42.3500312, 42.2814234, 42.334912, 42.3551473, 42.32992935, 42.3379418, 42.350675, 42.343451, 42.3340172, 42.3000984, nan, 42.3594924, 42.310412, 42.3487386, 42.36782045, 42.3502301, 42.3578153, 42.3621468, 42.3264153, 42.34712945, nan, nan, 42.322592, nan, 42.3489672, 42.3767055, 42.3683325, 42.336163, 42.336163, 42.3401342, 42.3490087, 42.3691041, 42.3331908, 42.3379387, 42.34315285, 42.33540795, 42.2818516, 42.3652935, 42.3400618, 36.77198965, 42.3912083, 42.3517318, 42.298263, 42.312474, 42.374924, 42.345596, nan, 42.2462086, 42.33511665, 42.400464, 52.985536, 42.3385722, 42.3306533, 42.3366072, nan, 42.3511128, 42.3106539, 42.3667045, 42.293126, 42.35184265, 42.3398175, 42.3588444, 42.317224, 42.39051, 42.3843509, 42.344126, 42.3399846, 42.3426644, 42.289375, 42.3496554, 42.3103337, 42.3484028, 34.1472316, 42.3440373, -41.2932518, 42.2868127, 42.935891, 42.3796991, 42.17368655, 42.3743352, 42.405219, 42.3487121, 42.3300161, 42.3596754, 42.351771, 42.2834319, 42.360653, 42.3528916, 42.3507067, 42.3307916, 42.3833663, 42.3384306, 42.3492202, 42.33540795, 42.350082, 42.349733, 42.3508198, 42.3613995, 42.3529947, 42.356282, 42.137775, 42.334317, 42.3432487, 42.3105415, 42.3373934, 14.8378415, 42.3611931, 42.9395288, 42.3383404, 42.352444, 42.3405937, 42.3362324, 42.3324596, 42.35215405, 42.3500312, 42.2814234, 42.334912, 42.3551473, 42.32992935, 42.3379418, 42.350675, 42.343451, 42.3340172, 42.3000984, nan, 42.3594924, 42.310412, 42.3487386, 42.36782045, 42.3502301, 42.3578153, 42.3621468, 42.3264153, 42.34712945, nan, nan, 42.322592, nan, 42.3489672, 42.3767055, 42.3683325, 42.336163, 42.336163, 42.3401342, 42.3490087, 42.3691041, 42.3331908, 42.3379387, 42.34315285, 42.33540795, 42.2818516, 42.3652935, 42.3400618, 36.77198965, 42.3912083, 42.3517318, 42.298263, 42.312474, 42.374924, 42.345596, nan, 42.2462086, 42.33511665, 42.400464, 52.985536, 42.3385722, 42.3306533, 42.3366072, nan, 42.3511128, 42.3106539, 42.3667045, 42.293126, 42.35184265, 42.3398175, 42.3588444, 42.317224, 42.39051, 42.3843509, 42.344126, 42.3399846, 42.3426644, 42.289375, 42.3496554, 42.3103337, 42.3484028, 34.1472316, 42.3440373, -41.2932518, 42.2868127, 42.935891, 42.3796991, 42.17368655]
<class 'list'>
List of Longitude:
[-71.0302838, -71.1345529, -71.137998, -71.0571473, -71.051589, -71.0709689, -71.0689392, -71.0669956, -71.1210369, -71.0797296, -71.1115857, -71.0014859, -71.1419973, -71.1000476, -71.16774026628, -71.1071825, -71.1043086, -71.1133692, -71.0619579, -71.0646277, -71.1352739, -72.5144729, -71.1043559, -71.057556, -71.114418, -71.105677862353, 120.8811589, -71.07134, -71.6181266, -71.1528793, -71.0625269, -71.150998, -71.1489684, -71.0918985, -71.1177049872685, -71.0774698, -71.0480849, -71.0260169, -71.0599538, -71.0908218455712, -71.1486134, -71.1629499, -71.0977163, -71.1059925, -71.057828, nan, -71.059303, -71.1075565, -71.1341589, -71.1266617287448, -71.1314227, -71.0561654, -71.0577938, -71.1007881, -71.0840042393235, nan, nan, -71.1002459, nan, -71.0956556, -71.0577890740004, -71.0747495, -71.0995139, -71.0995139, -71.0684271, -71.0885813, -71.0395763, -71.1095969, -71.0949801, -71.1619761802168, -71.16774026628, -71.0420034, -71.0601295, -71.0896922, -76.2292380281969, -71.0069943, -71.1253311, -71.0619959, -71.0589269, -71.0389389, -71.0813609, nan, -71.0048427, -71.158337534632, -70.9968109, -0.0337584, -71.110953166015, -71.0911626, -71.0893383, nan, -71.1157856, -71.0494946, -71.0677683, -71.0657379, -71.0550227973888, -71.1575631, -71.0572151, -71.1042799, -70.9971874, -71.0769705, -71.1382459, -71.1482657, -71.0848335, -71.1324559, -71.0638504, -71.2366332, -71.1404181, -118.1308664, -71.1426297, 174.7830529, -71.0830768, -81.2798437, -71.0228171, -83.3897170437666, -71.0302838, -71.1345529, -71.137998, -71.0571473, -71.051589, -71.0709689, -71.0689392, -71.0669956, -71.1210369, -71.0797296, -71.1115857, -71.0014859, -71.1419973, -71.1000476, -71.16774026628, -71.1071825, -71.1043086, -71.1133692, -71.0619579, -71.0646277, -71.1352739, -72.5144729, -71.1043559, -71.057556, -71.114418, -71.105677862353, 120.8811589, -71.07134, -71.6181266, -71.1528793, -71.0625269, -71.150998, -71.1489684, -71.0918985, -71.1177049872685, -71.0774698, -71.0480849, -71.0260169, -71.0599538, -71.0908218455712, -71.1486134, -71.1629499, -71.0977163, -71.1059925, -71.057828, nan, -71.059303, -71.1075565, -71.1341589, -71.1266617287448, -71.1314227, -71.0561654, -71.0577938, -71.1007881, -71.0840042393235, nan, nan, -71.1002459, nan, -71.0956556, -71.0577890740004, -71.0747495, -71.0995139, -71.0995139, -71.0684271, -71.0885813, -71.0395763, -71.1095969, -71.0949801, -71.1619761802168, -71.16774026628, -71.0420034, -71.0601295, -71.0896922, -76.2292380281969, -71.0069943, -71.1253311, -71.0619959, -71.0589269, -71.0389389, -71.0813609, nan, -71.0048427, -71.158337534632, -70.9968109, -0.0337584, -71.110953166015, -71.0911626, -71.0893383, nan, -71.1157856, -71.0494946, -71.0677683, -71.0657379, -71.0550227973888, -71.1575631, -71.0572151, -71.1042799, -70.9971874, -71.0769705, -71.1382459, -71.1482657, -71.0848335, -71.1324559, -71.0638504, -71.2366332, -71.1404181, -118.1308664, -71.1426297, 174.7830529, -71.0830768, -81.2798437, -71.0228171, -83.3897170437666, -71.0302838, -71.1345529, -71.137998, -71.0571473, -71.051589, -71.0709689, -71.0689392, -71.0669956, -71.1210369, -71.0797296, -71.1115857, -71.0014859, -71.1419973, -71.1000476, -71.16774026628, -71.1071825, -71.1043086, -71.1133692, -71.0619579, -71.0646277, -71.1352739, -72.5144729, -71.1043559, -71.057556, -71.114418, -71.105677862353, 120.8811589, -71.07134, -71.6181266, -71.1528793, -71.0625269, -71.150998, -71.1489684, -71.0918985, -71.1177049872685, -71.0774698, -71.0480849, -71.0260169, -71.0599538, -71.0908218455712, -71.1486134, -71.1629499, -71.0977163, -71.1059925, -71.057828, nan, -71.059303, -71.1075565, -71.1341589, -71.1266617287448, -71.1314227, -71.0561654, -71.0577938, -71.1007881, -71.0840042393235, nan, nan, -71.1002459, nan, -71.0956556, -71.0577890740004, -71.0747495, -71.0995139, -71.0995139, -71.0684271, -71.0885813, -71.0395763, -71.1095969, -71.0949801, -71.1619761802168, -71.16774026628, -71.0420034, -71.0601295, -71.0896922, -76.2292380281969, -71.0069943, -71.1253311, -71.0619959, -71.0589269, -71.0389389, -71.0813609, nan, -71.0048427, -71.158337534632, -70.9968109, -0.0337584, -71.110953166015, -71.0911626, -71.0893383, nan, -71.1157856, -71.0494946, -71.0677683, -71.0657379, -71.0550227973888, -71.1575631, -71.0572151, -71.1042799, -70.9971874, -71.0769705, -71.1382459, -71.1482657, -71.0848335, -71.1324559, -71.0638504, -71.2366332, -71.1404181, -118.1308664, -71.1426297, 174.7830529, -71.0830768, -81.2798437, -71.0228171, -83.3897170437666]
<class 'list'>
List of stop name:
['Airport , Boston', 'Alewife, Boston', 'Allston Street , Boston', 'Andrew , Boston', 'Aquarium , Boston', 'Arlington , Boston', 'Ashmont , Boston', 'Assembly , Boston', 'Babcock Street , Boston', 'Back Bay , Boston', 'Back of the Hill , Boston', 'Beachmont , Boston', 'Beaconsfield , Boston', 'Blandford Street , Boston', 'Boston College , Boston', 'Boston Univ Central , Boston', 'Boston Univ East , Boston', 'Boston Univ West , Boston', 'Bowdoin, Boston', 'Boylston , Boston', 'Braintree, Boston', 'Brandon Hall , Boston', 'Brigham Circle , Boston', 'Broadway , Boston', 'Brookline Hills , Boston', 'Brookline Village , Boston', 'Central , Boston', 'Charles/MGH , Boston', 'Chestnut Hill , Boston', 'Chestnut Hill Avenue , Boston', 'Chinatown , Boston', 'Chiswick Road , Boston', 'Cleveland Circle , Boston', 'Community College , Boston', 'Coolidge Corner , Boston', 'Copley , Boston', 'Davis , Boston', 'Dean Road , Boston', 'Downtown Crossing , Boston', 'Eliot , Boston', 'Englewood Avenue , Boston', 'Fairbanks Street , Boston', 'Fenway , Boston', 'Fenwood Road , Boston', 'Fields Corner , Boston', 'Forest Hills Orange Line, Boston', 'Government Center , Boston', 'Green Street , Boston', 'Griggs Street , Boston', 'Harvard , Boston', 'Harvard Avenue , Boston', 'Hawes Street , Boston', 'Haymarket , Boston', 'Heath Street , Boston', 'Hynes , Boston', 'JFK/UMASS Ashmont , Boston', 'JFK/UMASS Braintree , Boston', 'Jackson Square , Boston', 'Kendall/MIT , Boston', 'Kenmore , Boston', 'Kent Street , Boston', 'Lechmere , Boston', 'Longwood , Boston', 'Longwood Medical Area , Boston', 'Malden , Boston', 'Massachusetts Avenue , Boston', 'Maverick , Boston', 'Mission Park , Boston', 'Museum of Fine Arts , Boston', 'Newton Centre , Boston', 'Newton Highlands , Boston', 'North Quincy , Boston', 'North Station , Boston', 'Northeastern , Boston', 'Oak Grove, Boston', 'Orient Heights , Boston', 'Packards Corner , Boston', 'Park Street , Boston', 'Pleasant Street , Boston', 'Porter , Boston', 'Prudential , Boston', 'Quincy Adams , Boston', 'Quincy Center , Boston', 'Reservoir , Boston', 'Revere Beach , Boston', 'Riverside , Boston', 'Riverway , Boston', 'Roxbury Crossing , Boston', 'Ruggles , Boston', 'Saint Mary Street , Boston', 'Saint Paul Street , Boston', 'Savin Hill , Boston', 'Science Park , Boston', 'Shawmut , Boston', 'South Station , Boston', 'South Street , Boston', 'State Street , Boston', 'Stony Brook , Boston', 'Suffolk Downs , Boston', 'Sullivan Square , Boston', 'Summit Avenue , Boston', 'Sutherland Road , Boston', 'Symphony , Boston', 'Tappan Street , Boston', 'Tufts Medical Center , Boston', 'Waban , Boston', 'Warren Street , Boston', 'Washington Square , Boston', 'Washington Street , Boston', 'Wellington , Boston', 'Wollaston , Boston', 'Wonderland, Boston', 'Wood Island , Boston', 'Woodland , Boston', 'Airport , Boston', 'Alewife, Boston', 'Allston Street , Boston', 'Andrew , Boston', 'Aquarium , Boston', 'Arlington , Boston', 'Ashmont , Boston', 'Assembly , Boston', 'Babcock Street , Boston', 'Back Bay , Boston', 'Back of the Hill , Boston', 'Beachmont , Boston', 'Beaconsfield , Boston', 'Blandford Street , Boston', 'Boston College , Boston', 'Boston Univ Central , Boston', 'Boston Univ East , Boston', 'Boston Univ West , Boston', 'Bowdoin, Boston', 'Boylston , Boston', 'Braintree, Boston', 'Brandon Hall , Boston', 'Brigham Circle , Boston', 'Broadway , Boston', 'Brookline Hills , Boston', 'Brookline Village , Boston', 'Central , Boston', 'Charles/MGH , Boston', 'Chestnut Hill , Boston', 'Chestnut Hill Avenue , Boston', 'Chinatown , Boston', 'Chiswick Road , Boston', 'Cleveland Circle , Boston', 'Community College , Boston', 'Coolidge Corner , Boston', 'Copley , Boston', 'Davis , Boston', 'Dean Road , Boston', 'Downtown Crossing , Boston', 'Eliot , Boston', 'Englewood Avenue , Boston', 'Fairbanks Street , Boston', 'Fenway , Boston', 'Fenwood Road , Boston', 'Fields Corner , Boston', 'Forest Hills Orange Line, Boston', 'Government Center , Boston', 'Green Street , Boston', 'Griggs Street , Boston', 'Harvard , Boston', 'Harvard Avenue , Boston', 'Hawes Street , Boston', 'Haymarket , Boston', 'Heath Street , Boston', 'Hynes , Boston', 'JFK/UMASS Ashmont , Boston', 'JFK/UMASS Braintree , Boston', 'Jackson Square , Boston', 'Kendall/MIT , Boston', 'Kenmore , Boston', 'Kent Street , Boston', 'Lechmere , Boston', 'Longwood , Boston', 'Longwood Medical Area , Boston', 'Malden , Boston', 'Massachusetts Avenue , Boston', 'Maverick , Boston', 'Mission Park , Boston', 'Museum of Fine Arts , Boston', 'Newton Centre , Boston', 'Newton Highlands , Boston', 'North Quincy , Boston', 'North Station , Boston', 'Northeastern , Boston', 'Oak Grove, Boston', 'Orient Heights , Boston', 'Packards Corner , Boston', 'Park Street , Boston', 'Pleasant Street , Boston', 'Porter , Boston', 'Prudential , Boston', 'Quincy Adams , Boston', 'Quincy Center , Boston', 'Reservoir , Boston', 'Revere Beach , Boston', 'Riverside , Boston', 'Riverway , Boston', 'Roxbury Crossing , Boston', 'Ruggles , Boston', 'Saint Mary Street , Boston', 'Saint Paul Street , Boston', 'Savin Hill , Boston', 'Science Park , Boston', 'Shawmut , Boston', 'South Station , Boston', 'South Street , Boston', 'State Street , Boston', 'Stony Brook , Boston', 'Suffolk Downs , Boston', 'Sullivan Square , Boston', 'Summit Avenue , Boston', 'Sutherland Road , Boston', 'Symphony , Boston', 'Tappan Street , Boston', 'Tufts Medical Center , Boston', 'Waban , Boston', 'Warren Street , Boston', 'Washington Square , Boston', 'Washington Street , Boston', 'Wellington , Boston', 'Wollaston , Boston', 'Wonderland, Boston', 'Wood Island , Boston', 'Woodland , Boston', 'Airport , Boston', 'Alewife, Boston', 'Allston Street , Boston', 'Andrew , Boston', 'Aquarium , Boston', 'Arlington , Boston', 'Ashmont , Boston', 'Assembly , Boston', 'Babcock Street , Boston', 'Back Bay , Boston', 'Back of the Hill , Boston', 'Beachmont , Boston', 'Beaconsfield , Boston', 'Blandford Street , Boston', 'Boston College , Boston', 'Boston Univ Central , Boston', 'Boston Univ East , Boston', 'Boston Univ West , Boston', 'Bowdoin, Boston', 'Boylston , Boston', 'Braintree, Boston', 'Brandon Hall , Boston', 'Brigham Circle , Boston', 'Broadway , Boston', 'Brookline Hills , Boston', 'Brookline Village , Boston', 'Central , Boston', 'Charles/MGH , Boston', 'Chestnut Hill , Boston', 'Chestnut Hill Avenue , Boston', 'Chinatown , Boston', 'Chiswick Road , Boston', 'Cleveland Circle , Boston', 'Community College , Boston', 'Coolidge Corner , Boston', 'Copley , Boston', 'Davis , Boston', 'Dean Road , Boston', 'Downtown Crossing , Boston', 'Eliot , Boston', 'Englewood Avenue , Boston', 'Fairbanks Street , Boston', 'Fenway , Boston', 'Fenwood Road , Boston', 'Fields Corner , Boston', 'Forest Hills Orange Line, Boston', 'Government Center , Boston', 'Green Street , Boston', 'Griggs Street , Boston', 'Harvard , Boston', 'Harvard Avenue , Boston', 'Hawes Street , Boston', 'Haymarket , Boston', 'Heath Street , Boston', 'Hynes , Boston', 'JFK/UMASS Ashmont , Boston', 'JFK/UMASS Braintree , Boston', 'Jackson Square , Boston', 'Kendall/MIT , Boston', 'Kenmore , Boston', 'Kent Street , Boston', 'Lechmere , Boston', 'Longwood , Boston', 'Longwood Medical Area , Boston', 'Malden , Boston', 'Massachusetts Avenue , Boston', 'Maverick , Boston', 'Mission Park , Boston', 'Museum of Fine Arts , Boston', 'Newton Centre , Boston', 'Newton Highlands , Boston', 'North Quincy , Boston', 'North Station , Boston', 'Northeastern , Boston', 'Oak Grove, Boston', 'Orient Heights , Boston', 'Packards Corner , Boston', 'Park Street , Boston', 'Pleasant Street , Boston', 'Porter , Boston', 'Prudential , Boston', 'Quincy Adams , Boston', 'Quincy Center , Boston', 'Reservoir , Boston', 'Revere Beach , Boston', 'Riverside , Boston', 'Riverway , Boston', 'Roxbury Crossing , Boston', 'Ruggles , Boston', 'Saint Mary Street , Boston', 'Saint Paul Street , Boston', 'Savin Hill , Boston', 'Science Park , Boston', 'Shawmut , Boston', 'South Station , Boston', 'South Street , Boston', 'State Street , Boston', 'Stony Brook , Boston', 'Suffolk Downs , Boston', 'Sullivan Square , Boston', 'Summit Avenue , Boston', 'Sutherland Road , Boston', 'Symphony , Boston', 'Tappan Street , Boston', 'Tufts Medical Center , Boston', 'Waban , Boston', 'Warren Street , Boston', 'Washington Square , Boston', 'Washington Street , Boston', 'Wellington , Boston', 'Wollaston , Boston', 'Wonderland, Boston', 'Wood Island , Boston', 'Woodland , Boston']
<class 'list'>
List of Rate of trips/day:
[8.8, 8.8, 8.8, 8.8, 8.8, 35.1, 3.5, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 35.1, 5.3, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 35.1, 8.8, 8.8, 17.5, 8.8, 8.8, 8.8, 8.8, 8.8, 3.5, 8.8, 35.1, 8.8, 8.8, 8.8, 8.8, 8.8, 26.3, 8.8, 26.3, 3.5, 5.3, 8.8, 8.8, 26.3, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 5.3, 26.3, 8.8, 8.8, 8.8, 8.8, 43.9, 8.8, 8.8, 8.8, 5.3, 5.3, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 17.5, 3.5, 8.8, 3.5, 8.8, 8.8, 17.5, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 5.3, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 35.1, 4.4, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 35.1, 4.4, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 35.1, 8.8, 8.8, 17.5, 8.8, 8.8, 8.8, 8.8, 8.8, 4.4, 8.8, 36.8, 8.8, 8.8, 8.8, 8.8, 8.8, 28.1, 8.8, 26.3, 4.4, 4.4, 8.8, 8.8, 26.3, 8.8, 12.3, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 4.4, 28.1, 8.8, 8.8, 8.8, 8.8, 43.9, 8.8, 8.8, 8.8, 4.4, 4.4, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 17.5, 4.4, 12.3, 4.4, 8.8, 8.8, 17.5, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 4.4, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 35.1, 4.4, 8.8, 8.8, 8.8, 8.8, 7.9, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 35.1, 4.4, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 7.9, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 35.1, 8.8, 8.8, 17.5, 7.9, 8.8, 8.8, 8.8, 8.8, 4.4, 8.8, 35.1, 8.8, 8.8, 8.8, 8.8, 8.8, 26.3, 8.8, 26.3, 4.4, 4.4, 8.8, 8.8, 26.3, 8.8, 12.3, 8.8, 8.8, 7.9, 8.8, 8.8, 8.8, 8.8, 7.9, 7.9, 4.4, 26.3, 8.8, 7.9, 8.8, 8.8, 43.9, 8.8, 8.8, 8.8, 4.4, 4.4, 8.8, 7.9, 7.9, 8.8, 8.8, 8.8, 8.8, 17.5, 4.4, 12.3, 4.4, 8.8, 8.8, 17.5, 8.8, 7.9, 8.8, 8.8, 8.8, 8.8, 8.8, 8.8, 7.9, 8.8, 8.8, 8.8, 8.8, 4.4, 7.9, 8.8, 7.9]
<class 'list'>
Please suggest me how can I view proper bokeh plot
Upvotes: 1
Views: 808
Reputation: 3767
Trying to run your example I noticed two problems:
You will get error trying to plot missing values, to get rid of them you can use
stop_frame.dropna(inplace=True)
or fill them with some reasonable default using
stop_frame.fillna(0, inplace=True)
Your latitute
and longitude
coordinates are just scalar values.
In the texas example (you are modifying) the lats
and longs
consist of lists of floats defining borders for counties.
Therefore, trying to use patches
, which expects list of lists throws an
error in JS console could not set initial ranges...
Correcting it to patch
will still have trouble to fill the faces
passing a dict in fill_color
option in
p.patch('x', 'y', source=source,
fill_color={'field': 'rate', 'transform': color_mapper},
fill_alpha=0.7, line_color="black", line_width=0.5)
Changing it to i.e. fill_color='blue'
will plot lines
connecting your stops.
A betters solution for you would be using scatter
or circle
i.e.
p.circle('x', 'y', source=source,
fill_color={'field': 'rate', 'transform': color_mapper},
fill_alpha=0.7, line_color= 'black', line_width=0.5)
Even better, you could scale the circle radius with log of rate (or some other function)
source = ColumnDataSource(data=dict(
x=county_xs,
y=county_ys,
name=county_names,
rate=county_rates,
log_rate=np.log(county_rates),
))
...
p.circle('x', 'y', source=source,
radius='log_rate',
fill_color={'field': 'rate', 'transform': color_mapper},
fill_alpha=0.7, line_color= 'black', line_width=0.5)
EDIT: to answer the question in comment. You can plot i.e. Massachusetts counties by modifying the texas example. You can easily insert this piece of code just before plotting the stops.
from bokeh.sampledata.us_counties import data as counties
ma_counties = {
code: county for code, county in counties.items() if county["state"] == "ma"
}
ma_county_xs = [county["lats"] for county in ma_counties.values()]
ma_county_ys = [county["lons"] for county in ma_counties.values()]
ma_county_names = [county['name'] for county in ma_counties.values()]
ma_source = ColumnDataSource(data=dict(
x=ma_county_xs,
y=ma_county_ys,
name=ma_county_names
))
p.patches('x', 'y', source=ma_source,
fill_color='gray',
fill_alpha=0.7, line_color= 'black', line_width=0.5)
Note: with your setup, you will need to zoom in to see the map, because there are few outlier stops in your list.
Upvotes: 1