Hi, I’m attempting to map data in plotly express.
I’m running into issues with how the data is displayed.
It may be because I’m using the scatterplot differently to how it was intended.
This is a link to the chart:
https://chart-studio.plotly.com/~juniperberry/14/#/
I can’t figure out what’s causing the misprinted data, I’m wondering if anyone could help me! Sorry for the beginner question.
It’s an animation of data year by year, but for data from incorrect years appear e.g. 2017 data in the 2020 plot.
The data is a series of locations, each row is a different plot, color is red if it’s the first time a plot has appeared in that country, green if it’s not the first plot.
fig = px.scatter_mapbox(data_treemap,
lat="city.coords.lat",
lon="city.coords.long",
color_discrete_sequence=["red", "green"],
color="is_first_occurance",
size_max=15, zoom=1,
animation_frame="dateint",
mapbox_style="carto-positron",
hover_data={'city.country.name': True,
'city.name': True,
"city.coords.lat": False,
"city.coords.long": False,
"datedisplay": True,
"dateint": False},
)
Data
Int64Index: 214 entries, 213 to 0
Data columns (total 22 columns):
Unnamed: 0 214 non-null int64
id 214 non-null object
versionId 214 non-null object
eventDate 214 non-null object
city.id 214 non-null int64
city.name 214 non-null object
city.state 214 non-null object
city.stateCode 214 non-null object
city.coords.lat 214 non-null float64
city.coords.long 214 non-null float64
city.country.code 214 non-null object
city.country.name 214 non-null object
url 214 non-null object
continent 214 non-null object
date 214 non-null object
datedisplay 214 non-null object
dateint 214 non-null int64
occurance 214 non-null int64
first_occurance 214 non-null int64
is_first_occurance 214 non-null bool
count 214 non-null int64
world 214 non-null object
dtypes: bool(1), float64(2), int64(6), object(13)
memory usage: 26.1+ KB
> id eventDate city.id city.name city.state city.stateCode city.coords.lat city.coords.long city.country.code city.country.name continent date datedisplay dateint occurance first_occurance is_first_occurance count
0 7b99a2cc 28/02/2020 5368361 Los Angeles California CA 34.052 -118.244 US United States North America 28/02/2020 February 28 2020 2020 1 2014 FALSE 124
1 6398d2fb 08/02/2020 2160517 Launceston Tasmania TAS -41.45 147.1666667 AU Australia Oceania 08/02/2020 February 08 2020 2020 1 2014 FALSE 43
2 1398814d 31/01/2020 2147714 Sydney New South Wales NSW -33.86784996 151.2073231 AU Australia Oceania 31/01/2020 January 31 2020 2020 1 2014 FALSE 43
3 6398a6e3 28/01/2020 2158177 Melbourne Victoria VIC -37.81399656 144.9633229 AU Australia Oceania 28/01/2020 January 28 2020 2020 1 2014 FALSE 43
4 5b9ad3ec 24/11/2019 5391811 San Diego California CA 32.7153292 -117.1572551 US United States North America 24/11/2019 November 24 2019 2019 1 2014 FALSE 124
5 39be5f3 20/11/2019 5384170 Pomona California CA 34.0552886 -117.7522793 US United States North America 20/11/2019 November 20 2019 2019 1 2014 FALSE 124
6 339c6ce5 30/09/2019 5419384 Denver Colorado CO 39.7391536 -104.9847034 US United States North America 30/09/2019 September 30 2019 2019 1 2014 FALSE 124
7 39c654b 28/09/2019 4671654 Austin Texas TX 30.267153 -97.7430608 US United States North America 28/09/2019 September 28 2019 2019 1 2014 FALSE 124
8 1b9c1118 27/09/2019 4684888 Dallas Texas TX 32.7830556 -96.8066667 US United States North America 27/09/2019 September 27 2019 2019 1 2014 FALSE 124
9 39c25a7 23/09/2019 5308655 Phoenix Arizona AZ 33.4483771 -112.0740373 US United States North America 23/09/2019 September 23 2019 2019 1 2014 FALSE 124
10 2b9e34e2 19/07/2019 2172880 Byron Bay New South Wales NSW -28.65 153.6166667 AU Australia Oceania 19/07/2019 July 19 2019 2019 1 2014 FALSE 43
11 639c9a63 21/06/2019 2147714 Sydney New South Wales NSW -33.86784996 151.2073231 AU Australia Oceania 21/06/2019 June 21 2019 2019 1 2014 FALSE 43
12 3919d3b 30/05/2019 2174003 Brisbane Queensland QLD -27.46793573 153.0280924 AU Australia Oceania 30/05/2019 May 30 2019 2019 1 2014 FALSE 43
13 13904d21 28/05/2019 2147714 Sydney New South Wales NSW -33.86784996 151.2073231 AU Australia Oceania 28/05/2019 May 28 2019 2019 1 2014 FALSE 43
14 73907a01 25/05/2019 2142951 Woombye Queensland QLD -26.6666667 152.9666667 AU Australia Oceania 25/05/2019 May 25 2019 2019 1 2014 FALSE 43
15 6b907e7a 22/05/2019 2078025 Adelaide South Australia SA -34.9333333 138.6 AU Australia Oceania 22/05/2019 May 22 2019 2019 1 2014 FALSE 43
16 7.39E+06 21/05/2019 2158177 Melbourne Victoria VIC -37.81399656 144.9633229 AU Australia Oceania 21/05/2019 May 21 2019 2019 1 2014 FALSE 43
17 539053ed 18/05/2019 2073124 Darwin Northern Territory NT -12.46113366 130.8418465 AU Australia Oceania 18/05/2019 May 18 2019 2019 1 2014 FALSE 43
18 73902611 16/05/2019 2193733 Auckland Auckland E7 -36.8666667 174.7666667 NZ New Zealand Oceania 16/05/2019 May 16 2019 2019 1 2014 FALSE 14
19 b9035c2 14/05/2019 2192362 Christchurch Canterbury E9 -43.5333333 172.6333333 NZ New Zealand Oceania 14/05/2019 May 14 2019 2019 1 2014 FALSE 14
20 539053dd 11/05/2019 2166368 Forbes New South Wales NSW -33.3833333 148.0166667 AU Australia Oceania 11/05/2019 May 11 2019 2019 1 2014 FALSE 43
21 1b935d44 20/04/2019 4369596 Silver Spring Maryland MD 38.9906657 -77.026088 US United States North America 20/04/2019 April 20 2019 2019 1 2014 FALSE 124
22 4b8683c6 19/04/2019 5095281 Asbury Park New Jersey NJ 40.2203907 -74.0120817 US United States North America 19/04/2019 April 19 2019 2019 1 2014 FALSE 124
23 3936d03 18/04/2019 5128581 New York New York NY 40.7142691 -74.0059729 US United States North America 18/04/2019 April 18 2019 2019 1 2014 FALSE 124
24 7b9306e8 16/04/2019 4560349 Philadelphia Pennsylvania PA 39.952335 -75.163789 US United States North America 16/04/2019 April 16 2019 2019 1 2014 FALSE 124
25 7393120d 14/04/2019 4930956 Boston Massachusetts MA 42.3584308 -71.0597732 US United States North America 14/04/2019 April 14 2019 2019 1 2014 FALSE 124
26 6b931ee2 13/04/2019 6077243 Montreal Quebec QC 45.5088375 -73.587809 CA Canada North America 13/04/2019 April 13 2019 2019 1 2014 FALSE 15
27 139325bd 12/04/2019 6167865 Toronto Ontario ON 43.70011379 -79.41630419 CA Canada North America 12/04/2019 April 12 2019 2019 1 2014 FALSE 15
28 3933d0f 10/04/2019 4887398 Chicago Illinois IL 41.850033 -87.6500523 US United States North America 10/04/2019 April 10 2019 2019 1 2014 FALSE 124
29 b933d0a 09/04/2019 4887398 Chicago Illinois IL 41.850033 -87.6500523 US United States North America 09/04/2019 April 09 2019 2019 1 2014 FALSE 124
30 4b93c3da 08/04/2019 5045360 St. Paul Minnesota MN 44.9444101 -93.0932742 US United States North America 08/04/2019 April 08 2019 2019 1 2014 FALSE 124
31 5393cbc5 07/04/2019 4393217 Kansas City Missouri MO 39.0997266 -94.5785667 US United States North America 07/04/2019 April 07 2019 2019 1 2014 FALSE 124
32 6b93d2a2 06/04/2019 5419384 Denver Colorado CO 39.7391536 -104.9847034 US United States North America 06/04/2019 April 06 2019 2019 1 2014 FALSE 124
33 3393ec8d 01/04/2019 5809844 Seattle Washington WA 47.6062095 -122.3320708 US United States North America 01/04/2019 April 01 2019 2019 1 2014 FALSE 124
34 3b933428 29/03/2019 5391811 San Diego California CA 32.7153292 -117.1572551 US United States North America 29/03/2019 March 29 2019 2019 1 2014 FALSE 124
35 3938da7 27/03/2019 5368361 Los Angeles California CA 34.052 -118.244 US United States North America 27/03/2019 March 27 2019 2019 1 2014 FALSE 124
36 7b9dde18 26/03/2019 5392900 Santa Ana California CA 33.7455731 -117.8678338 US United States North America 26/03/2019 March 26 2019 2019 1 2014 FALSE 124
37 5b93bbe4 23/03/2019 2179537 Wellington Wellington G2 -41.27853616 174.7766393 NZ New Zealand Oceania 23/03/2019 March 23 2019 2019 1 2014 FALSE 14
38 23924c03 21/03/2019 2186280 Nelson Nelson F5 -41.283 173.283 NZ New Zealand Oceania 21/03/2019 March 21 2019 2019 1 2014 FALSE 14
39 3394207d 01/01/2019 7038902 Badung Bali 2 -8.4355 115.2437 ID Indonesia Asia 01/01/2019 January 01 2019 2019 1 2015 FALSE 2
40 13979d6d 09/11/2018 2193733 Auckland Auckland E7 -36.8666667 174.7666667 NZ New Zealand Oceania 09/11/2018 November 09 2018 2018 1 2014 FALSE 14
41 1b964110 06/11/2018 2174003 Brisbane Queensland QLD -27.46793573 153.0280924 AU Australia Oceania 06/11/2018 November 06 2018 2018 1 2014 FALSE 43
42 6b966a06 02/11/2018 2147714 Sydney New South Wales NSW -33.86784996 151.2073231 AU Australia Oceania 02/11/2018 November 02 2018 2018 1 2014 FALSE 43
43 4b96232e 26/10/2018 2158177 Melbourne Victoria VIC -37.81399656 144.9633229 AU Australia Oceania 26/10/2018 October 26 2018 2018 1 2014 FALSE 43
44 2.40E+06 19/10/2018 2063523 Perth Western Australia WA -31.9333333 115.8333333 AU Australia Oceania 19/10/2018 October 19 2018 2018 1 2014 FALSE 43
45 3be91cbc 29/09/2018 5133266 Queens New York NY 40.7498243 -73.7976337 US United States North America 29/09/2018 September 29 2018 2018 1 2014 FALSE 124
46 4be927ca 26/09/2018 5408076 West Hollywood California CA 34.0900091 -118.3617443 US United States North America 26/09/2018 September 26 2018 2018 1 2014 FALSE 124
47 3eba92b 09/07/2018 5918581 Cavendish Prince Edward Island PE 46.48342363 -63.38199913 CA Canada North America 09/07/2018 July 09 2018 2018 1 2014 FALSE 15
48 3bef747c 25/03/2018 4699066 Houston Texas TX 29.7632836 -95.3632715 US United States North America 25/03/2018 March 25 2018 2018 1 2014 FALSE 124
49 33e3283d 20/10/2017 5308655 Phoenix Arizona AZ 33.4483771 -112.0740373 US United States North America 20/10/2017 October 20 2017 2017 1 2014 FALSE 124
50 2be3e08e 15/10/2017 4671654 Austin Texas TX 30.267153 -97.7430608 US United States North America 15/10/2017 October 15 2017 2017 1 2014 FALSE 124
51 7be39a68 30/09/2017 5391811 San Diego California CA 32.7153292 -117.1572551 US United States North America 30/09/2017 September 30 2017 2017 1 2014 FALSE 124
52 5be27b3c 23/09/2017 5506956 Las Vegas Nevada NV 36.1749705 -115.137223 US United States North America 23/09/2017 September 23 2017 2017 1 2014 FALSE 124
53 7be22634 17/09/2017 5128581 New York New York NY 40.7142691 -74.0059729 US United States North America 17/09/2017 September 17 2017 2017 1 2014 FALSE 124
54 2be2086e 16/09/2017 4180439 Atlanta Georgia GA 33.7489954 -84.3879824 US United States North America 16/09/2017 September 16 2017 2017 1 2014 FALSE 124
55 7be2de50 03/09/2017 4560349 Philadelphia Pennsylvania PA 39.952335 -75.163789 US United States North America 03/09/2017 September 03 2017 2017 1 2014 FALSE 124
56 be2fd2a 01/09/2017 5809844 Seattle Washington WA 47.6062095 -122.3320708 US United States North America 01/09/2017 September 01 2017 2017 1 2014 FALSE 124
57 be741fe 10/06/2017 4268521 Bonner Springs Kansas KS 39.059726 -94.8835754 US United States North America 10/06/2017 June 10 2017 2017 1 2014 FALSE 124
58 1be741f0 09/06/2017 4407066 St. Louis Missouri MO 38.6272733 -90.1978889 US United States North America 09/06/2017 June 09 2017 2017 1 2014 FALSE 124
59 13e74d59 08/06/2017 4299276 Louisville Kentucky KY 38.2542376 -85.759407 US United States North America 08/06/2017 June 08 2017 2017 1 2014 FALSE 124
60 bee7dee 07/06/2017 4459343 Carrboro North Carolina NC 35.9101438 -79.0752895 US United States North America 07/06/2017 June 07 2017 2017 1 2014 FALSE 124
61 13e775ed 03/06/2017 4931972 Cambridge Massachusetts MA 42.375097 -71.1056079 US United States North America 03/06/2017 June 03 2017 2017 1 2014 FALSE 124
62 43e7136b 31/05/2017 6167865 Toronto Ontario ON 43.70011379 -79.41630419 CA Canada North America 31/05/2017 May 31 2017 2017 1 2014 FALSE 15
63 6be71a96 28/05/2017 4508722 Cincinnati Ohio OH 39.1620036 -84.4568863 US United States North America 28/05/2017 May 28 2017 2017 1 2014 FALSE 124
64 53e73b9d 27/05/2017 4990729 Detroit Michigan MI 42.331427 -83.0457538 US United States North America 27/05/2017 May 27 2017 2017 1 2014 FALSE 124
65 4be73b9e 26/05/2017 4887398 Chicago Illinois IL 41.850033 -87.6500523 US United States North America 26/05/2017 May 26 2017 2017 1 2014 FALSE 124
66 5be73b98 25/05/2017 5263045 Milwaukee Wisconsin WI 43.0389025 -87.9064736 US United States North America 25/05/2017 May 25 2017 2017 1 2014 FALSE 124
67 43e88f6f 20/05/2017 5398563 Stanford California CA 37.424106 -122.1660756 US United States North America 20/05/2017 May 20 2017 2017 1 2014 FALSE 124
68 63e63a4b 21/04/2017 5359446 Indio California CA 33.7205771 -116.2155619 US United States North America 21/04/2017 April 21 2017 2017 1 2014 FALSE 124
69 4be6e7f6 14/04/2017 5359446 Indio California CA 33.7205771 -116.2155619 US United States North America 14/04/2017 April 14 2017 2017 1 2014 FALSE 124
70 7bf91eec 17/03/2017 2643743 London England ENG 51.50841526 -0.125532746 GB United Kingdom Europe 17/03/2017 March 17 2017 2017 1 2014 FALSE 6
71 3f929d7 15/03/2017 2643123 Manchester England ENG 53.48094643 -2.237434387 GB United Kingdom Europe 15/03/2017 March 15 2017 2017 1 2014 FALSE 6
72 5bf93f98 13/03/2017 2988507 Paris ÃŽle-de-France A8 48.85341 2.3488 FR France Europe 13/03/2017 March 13 2017 2017 1 2017 TRUE 1
73 2bf9c00e 12/03/2017 2801472 Borgerhout Antwerp BE.AN 51.117 5.083 BE Belgium Europe 12/03/2017 March 12 2017 2017 1 2017 TRUE 1
74 73f9d6b1 10/03/2017 2886242 Cologne North Rhine-Westphalia 7 50.9333333 6.95 DE Germany Europe 10/03/2017 March 10 2017 2017 1 2017 TRUE 2
75 63f9e23f 08/03/2017 2759794 Amsterdam North Holland 7 52.373 4.9 NL Netherlands Europe 08/03/2017 March 08 2017 2017 1 2017 TRUE 1
76 1bf9ede0 06/03/2017 2950159 Berlin Berlin 16 52.5166667 13.4 DE Germany Europe 06/03/2017 March 06 2017 2017 1 2017 TRUE 2
77 63f9fa2b 04/03/2017 2618425 Copenhagen Capital Region 17 55.6776812 12.5709343 DK Denmark Europe 04/03/2017 March 04 2017 2017 1 2017 TRUE 1
78 6bf9fa36 03/03/2017 2711537 Gothenburg Västra Götaland County 28 57.70716231 11.96679354 SE Sweden Europe 03/03/2017 March 03 2017 2017 1 2017 TRUE 2
79 73f9fa35 02/03/2017 2673730 Stockholm Stockholm County 26 59.33257654 18.06490302 SE Sweden Europe 02/03/2017 March 02 2017 2017 1 2017 TRUE 2
80 4be5038a 12/02/2017 5074472 Omaha Nebraska NE 41.2586096 -95.937792 US United States North America 12/02/2017 February 12 2017 2017 1 2014 FALSE 124
81 13fb4515 08/01/2017 2071223 Fremantle Western Australia WA -32.05 115.7666667 AU Australia Oceania 08/01/2017 January 08 2017 2017 1 2014 FALSE 43
82 3fb4db7 05/01/2017 2186442 Mount Maunganui Bay of Plenty E8 -37.617 176.183 NZ New Zealand Oceania 05/01/2017 January 05 2017 2017 1 2014 FALSE 14
83 33fb6405 01/01/2017 2147714 Sydney New South Wales NSW -33.86784996 151.2073231 AU Australia Oceania 01/01/2017 January 01 2017 2017 1 2014 FALSE 43