Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,18 @@ import plotly.graph_objects as go
|
|
6 |
|
7 |
st.set_page_config(page_title="Plotly Graphing Libraries",layout='wide')
|
8 |
|
9 |
-
# https://plotly.com/python/treemaps/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
df = px.data.tips()
|
12 |
fig = px.treemap(df, path=[px.Constant("all"), 'sex', 'day', 'time'],
|
@@ -19,15 +30,6 @@ fig.update_traces(marker=dict(cornerradius=5))
|
|
19 |
st.plotly_chart(fig, use_container_width=True)
|
20 |
|
21 |
|
22 |
-
df = px.data.gapminder().query("year == 2007")
|
23 |
-
fig = px.treemap(df, path=[px.Constant("world"), 'continent', 'country'], values='pop',
|
24 |
-
color='lifeExp', hover_data=['iso_alpha'],
|
25 |
-
color_continuous_scale='RdBu',
|
26 |
-
color_continuous_midpoint=np.average(df['lifeExp'], weights=df['pop']))
|
27 |
-
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
|
28 |
-
#fig.show()
|
29 |
-
st.plotly_chart(fig, use_container_width=True)
|
30 |
-
|
31 |
|
32 |
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/96c0bd/sunburst-coffee-flavors-complete.csv')
|
33 |
fig = go.Figure(go.Treemap(
|
|
|
6 |
|
7 |
st.set_page_config(page_title="Plotly Graphing Libraries",layout='wide')
|
8 |
|
9 |
+
st.markdown("# Treemaps: https://plotly.com/python/treemaps/")
|
10 |
+
|
11 |
+
|
12 |
+
df = px.data.gapminder().query("year == 2007")
|
13 |
+
fig = px.treemap(df, path=[px.Constant("world"), 'continent', 'country'], values='pop',
|
14 |
+
color='lifeExp', hover_data=['iso_alpha'],
|
15 |
+
color_continuous_scale='RdBu',
|
16 |
+
color_continuous_midpoint=np.average(df['lifeExp'], weights=df['pop']))
|
17 |
+
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
|
18 |
+
#fig.show()
|
19 |
+
st.plotly_chart(fig, use_container_width=True)
|
20 |
+
|
21 |
|
22 |
df = px.data.tips()
|
23 |
fig = px.treemap(df, path=[px.Constant("all"), 'sex', 'day', 'time'],
|
|
|
30 |
st.plotly_chart(fig, use_container_width=True)
|
31 |
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/96c0bd/sunburst-coffee-flavors-complete.csv')
|
35 |
fig = go.Figure(go.Treemap(
|