Spaces:
Sleeping
Sleeping
File size: 2,012 Bytes
e88abf9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
import solara
import plotly.express as px
from utils import selected_template
@solara.component
def AnimatedPlots():
with solara.Column(gap="20px", align = "stretch") as main:
solara.Markdown(f"#Animated Plots")
# Create an animated plot that you can use to cycle through continent
# GDP & life expectancy changes
df_cnt = px.data.gapminder()
fig1= px.scatter(df_cnt, x="gdpPercap", y="lifeExp", animation_frame="year",
animation_group="country",
template=selected_template.value,
size="pop", color="continent", hover_name="country",
log_x=True, size_max=55, range_x=[100,100000], range_y=[25,90])
# Watch as bars chart population changes
fig2 =px.bar(df_cnt, x="continent", y="pop", color="continent",template=selected_template.value,
animation_frame="year", animation_group="country", range_y=[0,4000000000])
solara.Markdown("""
```python
# Create an animated plot that you can use to cycle through continent
# GDP & life expectancy changes
df_cnt = px.data.gapminder()
px.scatter(df_cnt, x="gdpPercap", y="lifeExp", animation_frame="year",
animation_group="country",
size="pop", color="continent", hover_name="country",
log_x=True, size_max=55, range_x=[100,100000], range_y=[25,90])
# Watch as bars chart population changes
px.bar(df_cnt, x="continent", y="pop", color="continent",
animation_frame="year", animation_group="country", range_y=[0,4000000000])
```
"""
)
solara.display(fig1)
solara.display(fig2)
return main
|