删除 go.Scattermapbox 上的工具提示限制
Removing tooltip limit on go.Scattermapbox
我写了一些代码主要是基于一些代码here.
我遇到的问题是,如果绘图上有超过 88 个点,工具提示将不再显示,即当我取消注释 df = df.head(88)
时,工具提示将显示,否则不会显示。
我查看了 go.Scattermapbox
的文档,但找不到有关工具提示限制的任何信息。
关于如何取消此限制有任何想法吗?
我使用的代码:
import pandas as pd
import plotly.graph_objects as go
df = pd.DataFrame({'lat': {23: -31.9555965, 28: 45.4935271, 33: 44.9334927, 62: 39.8818997, 63: 58.3619916, 69: 57.7122365, 70: 33.658606, 89: 34.4358294, 90: 31.7967756, 97: 40.7464969, 100: 37.8628505, 109: 57.6946769, 113: 37.7051306, 114: 37.7051306, 115: 43.7160616, 128: 47.8531475, 140: 45.4935271, 145: 57.8037097, 160: 37.9296403, 174: 37.3589101, 192: 37.8157595, 228: 24.8254532, 266: 30.616276, 284: 52.5173449, 292: 31.2841598, 327: 34.0181246, 328: 19.0132891, 331: 46.5472456, 332: 40.4161588, 345: -29.0961262, 353: 44.9847287, 366: -31.9555965, 445: 30.616276, 461: 1.402303, 471: 19.0289954, 472: 34.4964601, 476: 62.9941952, 490: 12.9967012, 516: 42.5600931, 523: 6.5243793, 538: 32.4899749, 539: 26.4870674, 577: 13.0863319, 598: 46.0710668, 603: 37.081944, 607: 25.2854473, 609: 30.616276, 612: 29.864615, 615: 34.2959487, 617: 44.4159833, 623: -27.979443, 624: 22.5251352, 631: 33.8213636, 637: 31.6098637, 647: 40.1403449, 650: 3.0889937, 654: 44.4159833, 694: -29.0961262, 699: 30.8685434, 704: 40.410608, 707: 50.139577, 721: 53.8102024, 722: 40.6488134, 729: 17.2766381, 730: 43.6670521, 757: 13.7563309, 762: 17.3680124, 793: 22.2873657, 794: 51.8985143, 798: 34.6766662, 827: 18.5882884, 869: 45.4935271, 870: 45.4935271, 876: 45.4931521, 932: 50.139577, 936: 34.7124594, 960: 62.9941952, 999: 62.9941952, 1087: 40.7024477, 1126: 29.0946277, 1130: 9.2815309, 1134: 40.527271, 1142: 12.9336736, 1220: 19.9673711, 1266: 44.4159833, 1269: -10.9282126, 1296: 39.6837226, 1334: 33.4240128, 1336: 99.999999},
'lon': {23: 28.3512339, 28: -122.5761229, 33: 7.5407494, 62: -105.0081165, 63: 11.9203063, 69: 11.9173251, 70: -117.25455, 89: -119.8276389, 90: -92.4360795, 97: -74.0094471, 100: -83.890515, 109: 11.9599817, 113: -89.2209036, 114: -89.2209036, 115: -71.5305482, 128: -120.1372348, 140: -122.5761229, 145: 11.9088652, 160: -84.0873524, 174: -85.3515392, 192: -109.4375409, 228: 67.0382126, 266: 114.3571936, 284: 13.4630849, 292: -97.0631969, 327: -5.0078451, 328: 72.8548981, 331: 0.2987701, 332: -3.680072, 345: 26.1669115, 353: -93.2759643, 366: 28.3512339, 445: 114.3571936, 461: 103.91239, 471: 72.8881464, 472: -118.3346172, 476: 14.9732682, 490: 77.758197, 516: -83.1453042, 523: 3.3792057, 538: -101.7590348, 539: 80.3491599, 577: 80.2871828, 598: 13.2345794, 603: -121.596947, 607: 51.5310398, 609: 114.3571936, 612: -89.970519, 615: -105.8713792, 617: -118.9414017, 623: 26.7378585, 624: 88.4125502, 631: -116.7937179, 637: -93.4705439, 647: -77.3670988, 650: 101.6128821, 654: -118.9414017, 694: 26.1669115, 699: -86.9723804, 704: -74.422545, 707: 8.736725, 721: -8.9025117, 722: -73.5535234, 729: 78.4865602, 730: -79.3850226, 757: 100.5017651, 762: 78.430237, 793: 114.1391271, 794: -8.4756035, 798: -88.67066, 827: 73.8169099, 869: -122.5761229, 870: -122.5761229, 876: -122.5761506, 932: 8.736725, 936: -77.5796731, 960: 14.9732682, 999: 14.9732682, 1087: 14.5363969, 1126: 70.9023768, 1130: 76.631163, 1134: -74.230729, 1142: 77.5899649, 1220: 85.6229296, 1266: -118.9414017, 1269: -37.0841327, 1296: -75.7496572, 1334: -111.9421961, 1336: 0.0},
'id': {23: 52, 28: 57, 33: 63, 62: 122, 63: 123, 69: 131, 70: 133, 89: 159, 90: 160, 97: 169, 100: 172, 109: 185, 113: 190, 114: 191, 115: 192, 128: 208, 140: 227, 145: 232, 160: 255, 174: 278, 192: 305, 228: 349, 266: 412, 284: 437, 292: 448, 327: 501, 328: 502, 331: 507, 332: 508, 345: 527, 353: 538, 366: 558, 445: 671, 461: 697, 471: 711, 472: 712, 476: 717, 490: 743, 516: 787, 523: 796, 538: 813, 539: 814, 577: 869, 598: 897, 603: 902, 607: 910, 609: 912, 612: 918, 615: 921, 617: 923, 623: 932, 624: 933, 631: 944, 637: 952, 647: 968, 650: 975, 654: 979, 694: 1039, 699: 1046, 704: 1053, 707: 1056, 721: 1082, 722: 1083, 729: 1092, 730: 1093, 757: 1125, 762: 1130, 793: 1175, 794: 1176, 798: 1184, 827: 1227, 869: 1286, 870: 1287, 876: 1296, 932: 1375, 936: 1384, 960: 1422, 999: 1485, 1087: 1606, 1126: 1654, 1130: 1659, 1134: 1666, 1142: 1680, 1220: 1785, 1266: 1851, 1269: 1856, 1296: 1895, 1334: 1955, 1336: 1959}})
# df = df.head(88)
user_lat = df.lat
user_lon = df.lon
user_id = df.id
fig = go.Figure()
fig.add_trace(go.Scattermapbox(
lat=user_lat,
lon=user_lon,
mode='markers',
marker=dict(
size=10,
color='rgb(177, 242, 172)',
opacity=0.7
),
text=user_id,
hoverinfo='text'
))
fig.update_layout(
title='',
autosize=True,
hovermode='closest',
showlegend=False,
mapbox_style="open-street-map"
)
fig.show()
这不是行数限制,而是数据质量问题。 https://docs.mapbox.com/help/glossary/lat-lon/
df.loc[1336, "lat"] = df.sample(1)["lat"].values[0]
df.loc[1336, "lon"] = df.sample(1)["lon"].values[0]
然后89个点全部出图。即使 df = df.tail(5)
也没有工具提示
我写了一些代码主要是基于一些代码here.
我遇到的问题是,如果绘图上有超过 88 个点,工具提示将不再显示,即当我取消注释 df = df.head(88)
时,工具提示将显示,否则不会显示。
我查看了 go.Scattermapbox
的文档,但找不到有关工具提示限制的任何信息。
关于如何取消此限制有任何想法吗?
我使用的代码:
import pandas as pd
import plotly.graph_objects as go
df = pd.DataFrame({'lat': {23: -31.9555965, 28: 45.4935271, 33: 44.9334927, 62: 39.8818997, 63: 58.3619916, 69: 57.7122365, 70: 33.658606, 89: 34.4358294, 90: 31.7967756, 97: 40.7464969, 100: 37.8628505, 109: 57.6946769, 113: 37.7051306, 114: 37.7051306, 115: 43.7160616, 128: 47.8531475, 140: 45.4935271, 145: 57.8037097, 160: 37.9296403, 174: 37.3589101, 192: 37.8157595, 228: 24.8254532, 266: 30.616276, 284: 52.5173449, 292: 31.2841598, 327: 34.0181246, 328: 19.0132891, 331: 46.5472456, 332: 40.4161588, 345: -29.0961262, 353: 44.9847287, 366: -31.9555965, 445: 30.616276, 461: 1.402303, 471: 19.0289954, 472: 34.4964601, 476: 62.9941952, 490: 12.9967012, 516: 42.5600931, 523: 6.5243793, 538: 32.4899749, 539: 26.4870674, 577: 13.0863319, 598: 46.0710668, 603: 37.081944, 607: 25.2854473, 609: 30.616276, 612: 29.864615, 615: 34.2959487, 617: 44.4159833, 623: -27.979443, 624: 22.5251352, 631: 33.8213636, 637: 31.6098637, 647: 40.1403449, 650: 3.0889937, 654: 44.4159833, 694: -29.0961262, 699: 30.8685434, 704: 40.410608, 707: 50.139577, 721: 53.8102024, 722: 40.6488134, 729: 17.2766381, 730: 43.6670521, 757: 13.7563309, 762: 17.3680124, 793: 22.2873657, 794: 51.8985143, 798: 34.6766662, 827: 18.5882884, 869: 45.4935271, 870: 45.4935271, 876: 45.4931521, 932: 50.139577, 936: 34.7124594, 960: 62.9941952, 999: 62.9941952, 1087: 40.7024477, 1126: 29.0946277, 1130: 9.2815309, 1134: 40.527271, 1142: 12.9336736, 1220: 19.9673711, 1266: 44.4159833, 1269: -10.9282126, 1296: 39.6837226, 1334: 33.4240128, 1336: 99.999999},
'lon': {23: 28.3512339, 28: -122.5761229, 33: 7.5407494, 62: -105.0081165, 63: 11.9203063, 69: 11.9173251, 70: -117.25455, 89: -119.8276389, 90: -92.4360795, 97: -74.0094471, 100: -83.890515, 109: 11.9599817, 113: -89.2209036, 114: -89.2209036, 115: -71.5305482, 128: -120.1372348, 140: -122.5761229, 145: 11.9088652, 160: -84.0873524, 174: -85.3515392, 192: -109.4375409, 228: 67.0382126, 266: 114.3571936, 284: 13.4630849, 292: -97.0631969, 327: -5.0078451, 328: 72.8548981, 331: 0.2987701, 332: -3.680072, 345: 26.1669115, 353: -93.2759643, 366: 28.3512339, 445: 114.3571936, 461: 103.91239, 471: 72.8881464, 472: -118.3346172, 476: 14.9732682, 490: 77.758197, 516: -83.1453042, 523: 3.3792057, 538: -101.7590348, 539: 80.3491599, 577: 80.2871828, 598: 13.2345794, 603: -121.596947, 607: 51.5310398, 609: 114.3571936, 612: -89.970519, 615: -105.8713792, 617: -118.9414017, 623: 26.7378585, 624: 88.4125502, 631: -116.7937179, 637: -93.4705439, 647: -77.3670988, 650: 101.6128821, 654: -118.9414017, 694: 26.1669115, 699: -86.9723804, 704: -74.422545, 707: 8.736725, 721: -8.9025117, 722: -73.5535234, 729: 78.4865602, 730: -79.3850226, 757: 100.5017651, 762: 78.430237, 793: 114.1391271, 794: -8.4756035, 798: -88.67066, 827: 73.8169099, 869: -122.5761229, 870: -122.5761229, 876: -122.5761506, 932: 8.736725, 936: -77.5796731, 960: 14.9732682, 999: 14.9732682, 1087: 14.5363969, 1126: 70.9023768, 1130: 76.631163, 1134: -74.230729, 1142: 77.5899649, 1220: 85.6229296, 1266: -118.9414017, 1269: -37.0841327, 1296: -75.7496572, 1334: -111.9421961, 1336: 0.0},
'id': {23: 52, 28: 57, 33: 63, 62: 122, 63: 123, 69: 131, 70: 133, 89: 159, 90: 160, 97: 169, 100: 172, 109: 185, 113: 190, 114: 191, 115: 192, 128: 208, 140: 227, 145: 232, 160: 255, 174: 278, 192: 305, 228: 349, 266: 412, 284: 437, 292: 448, 327: 501, 328: 502, 331: 507, 332: 508, 345: 527, 353: 538, 366: 558, 445: 671, 461: 697, 471: 711, 472: 712, 476: 717, 490: 743, 516: 787, 523: 796, 538: 813, 539: 814, 577: 869, 598: 897, 603: 902, 607: 910, 609: 912, 612: 918, 615: 921, 617: 923, 623: 932, 624: 933, 631: 944, 637: 952, 647: 968, 650: 975, 654: 979, 694: 1039, 699: 1046, 704: 1053, 707: 1056, 721: 1082, 722: 1083, 729: 1092, 730: 1093, 757: 1125, 762: 1130, 793: 1175, 794: 1176, 798: 1184, 827: 1227, 869: 1286, 870: 1287, 876: 1296, 932: 1375, 936: 1384, 960: 1422, 999: 1485, 1087: 1606, 1126: 1654, 1130: 1659, 1134: 1666, 1142: 1680, 1220: 1785, 1266: 1851, 1269: 1856, 1296: 1895, 1334: 1955, 1336: 1959}})
# df = df.head(88)
user_lat = df.lat
user_lon = df.lon
user_id = df.id
fig = go.Figure()
fig.add_trace(go.Scattermapbox(
lat=user_lat,
lon=user_lon,
mode='markers',
marker=dict(
size=10,
color='rgb(177, 242, 172)',
opacity=0.7
),
text=user_id,
hoverinfo='text'
))
fig.update_layout(
title='',
autosize=True,
hovermode='closest',
showlegend=False,
mapbox_style="open-street-map"
)
fig.show()
这不是行数限制,而是数据质量问题。 https://docs.mapbox.com/help/glossary/lat-lon/
df.loc[1336, "lat"] = df.sample(1)["lat"].values[0]
df.loc[1336, "lon"] = df.sample(1)["lon"].values[0]
然后89个点全部出图。即使 df = df.tail(5)