gpt4 book ai didi

python - 在 map Bokeh 上执行面积图时,它显示空白框并且不起作用

转载 作者:太空宇宙 更新时间:2023-11-03 15:22:14 24 4
gpt4 key购买 nike

我试图绘制特定地铁站每天的出行率。我尝试使用 Bokeh 来绘制它。当我使用 Bokeh 示例数据时,它工作正常,但是,当我传递必须为其绘制 Bokeh 的数据时,它会显示空白的 Bokeh 图。

我正在使用以下代码:

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 got I want plot like this

我在绘图中使用以下数据:

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'>

请建议我如何查看正确的 Bokeh 图

最佳答案

尝试运行您的示例时我注意到两个问题:

  1. 尝试绘制缺失值时会出现错误,要消除它们,您可以使用

    stop_frame.dropna(inplace=True)

    或者使用一些合理的默认值填充它们

    stop_frame.fillna(0, inplace=True)
  2. 您的纬度经度坐标只是标量值。在 texas示例(您正在修改)latslongs由定义县边界的 float 列表组成。

    因此,尝试使用 patches(需要列表列表)会抛出JS 控制台中的错误无法设置初始范围...

    将其修正为patch仍然无法填充面部在

    中的 fill_color 选项中传递一个字典
    p.patch('x', 'y', source=source,
    fill_color={'field': 'rate', 'transform': color_mapper},
    fill_alpha=0.7, line_color="black", line_width=0.5)

    将其更改为 fill_color='blue' 将绘制线条连接您的站点。

    更好的解决方案是使用scattercircle,即

    p.circle('x', 'y', source=source,
    fill_color={'field': 'rate', 'transform': color_mapper},
    fill_alpha=0.7, line_color= 'black', line_width=0.5)

    更好的是,您可以使用速率的对数来缩放圆半径(或其他一些功能)

    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)

编辑:回答评论中的问题。您可以通过修改德克萨斯州的示例来绘制马萨诸塞州的县。您可以在绘制止损点之前轻松插入这段代码。

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)

注意:根据您的设置,您需要放大才能查看 map ,因为您的列表中几乎没有异常站点。

关于python - 在 map Bokeh 上执行面积图时,它显示空白框并且不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43440890/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com