Skip to content

Commit dbf7c26

Browse files
authored
Merge pull request #5377 from yaoxiao1999/patch-2
Update code example in animations.md
2 parents 9928ba7 + d244457 commit dbf7c26

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

doc/python/animations.md

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -339,27 +339,6 @@ sliders_dict = {
339339
"steps": []
340340
}
341341

342-
# make data
343-
year = 1952
344-
for continent in continents:
345-
dataset_by_year = dataset[dataset["year"] == year]
346-
dataset_by_year_and_cont = dataset_by_year[
347-
dataset_by_year["continent"] == continent]
348-
349-
data_dict = {
350-
"x": list(dataset_by_year_and_cont["lifeExp"]),
351-
"y": list(dataset_by_year_and_cont["gdpPercap"]),
352-
"mode": "markers",
353-
"text": list(dataset_by_year_and_cont["country"]),
354-
"marker": {
355-
"sizemode": "area",
356-
"sizeref": 200000,
357-
"size": list(dataset_by_year_and_cont["pop"])
358-
},
359-
"name": continent
360-
}
361-
fig_dict["data"].append(data_dict)
362-
363342
# make frames
364343
for year in years:
365344
frame = {"data": [], "name": str(year)}
@@ -396,6 +375,9 @@ for year in years:
396375

397376
fig_dict["layout"]["sliders"] = [sliders_dict]
398377

378+
# make data
379+
fig_dict["data"] = fig_dict["frames"][0]['data']
380+
399381
fig = go.Figure(fig_dict)
400382

401383
fig.show()

0 commit comments

Comments
 (0)