Spaces:
Runtime error
Runtime error
Upload 3 files
Browse files- app.py +56 -0
- bloom_dataset.pkl +3 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import numpy as np
|
3 |
+
import plotly.express as px
|
4 |
+
import pandas as pd
|
5 |
+
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'],
|
13 |
+
values='total_bill', color='time',
|
14 |
+
color_discrete_map={'(?)':'lightgrey', 'Lunch':'gold', 'Dinner':'darkblue'})
|
15 |
+
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
|
16 |
+
#fig.show()
|
17 |
+
fig.update_traces(marker=dict(cornerradius=5))
|
18 |
+
|
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(
|
34 |
+
ids = df.ids,
|
35 |
+
labels = df.labels,
|
36 |
+
parents = df.parents,
|
37 |
+
pathbar_textfont_size=15,
|
38 |
+
root_color="lightgrey"
|
39 |
+
))
|
40 |
+
fig.update_layout(
|
41 |
+
uniformtext=dict(minsize=10, mode='hide'),
|
42 |
+
margin = dict(t=50, l=25, r=25, b=25)
|
43 |
+
)
|
44 |
+
#fig.show()
|
45 |
+
st.plotly_chart(fig, use_container_width=True)
|
46 |
+
|
47 |
+
|
48 |
+
df = pd.read_pickle('bloom_dataset.pkl')
|
49 |
+
fig = px.treemap(df, path=[px.Constant("ROOTS"), 'Macroarea', 'Family', 'Genus', 'Language', 'dataset_name'],
|
50 |
+
values='num_bytes', maxdepth=4)
|
51 |
+
fig.update_traces(root_color="pink")
|
52 |
+
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
|
53 |
+
|
54 |
+
st.plotly_chart(fig, use_container_width=True)
|
55 |
+
|
56 |
+
|
bloom_dataset.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:27b17d22a1763de24c70da9ab87a6e6887cfdb7b17570e9758f4033217cbaf42
|
3 |
+
size 88499
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
plotly
|
2 |
+
pandas
|
3 |
+
protobuf~=3.19.0
|