awacke1 commited on
Commit
b9ebe8b
·
1 Parent(s): 6970523

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +54 -0
app.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ import plotly.express as px
4
+ import pandas as pd
5
+ st.set_page_config(page_title="Plotly Graphing Libraries",layout='wide')
6
+
7
+ # https://plotly.com/python/treemaps/
8
+
9
+ df = px.data.tips()
10
+ fig = px.treemap(df, path=[px.Constant("all"), 'sex', 'day', 'time'],
11
+ values='total_bill', color='time',
12
+ color_discrete_map={'(?)':'lightgrey', 'Lunch':'gold', 'Dinner':'darkblue'})
13
+ fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
14
+ #fig.show()
15
+ fig.update_traces(marker=dict(cornerradius=5))
16
+
17
+ st.plotly_chart(fig, use_container_width=True)
18
+
19
+
20
+ df = px.data.gapminder().query("year == 2007")
21
+ fig = px.treemap(df, path=[px.Constant("world"), 'continent', 'country'], values='pop',
22
+ color='lifeExp', hover_data=['iso_alpha'],
23
+ color_continuous_scale='RdBu',
24
+ color_continuous_midpoint=np.average(df['lifeExp'], weights=df['pop']))
25
+ fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
26
+ #fig.show()
27
+ st.plotly_chart(fig, use_container_width=True)
28
+
29
+
30
+ df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/96c0bd/sunburst-coffee-flavors-complete.csv')
31
+ fig = go.Figure(go.Treemap(
32
+ ids = df.ids,
33
+ labels = df.labels,
34
+ parents = df.parents,
35
+ pathbar_textfont_size=15,
36
+ root_color="lightgrey"
37
+ ))
38
+ fig.update_layout(
39
+ uniformtext=dict(minsize=10, mode='hide'),
40
+ margin = dict(t=50, l=25, r=25, b=25)
41
+ )
42
+ #fig.show()
43
+ st.plotly_chart(fig, use_container_width=True)
44
+
45
+
46
+ df = pd.read_pickle('bloom_dataset.pkl')
47
+ fig = px.treemap(df, path=[px.Constant("ROOTS"), 'Macroarea', 'Family', 'Genus', 'Language', 'dataset_name'],
48
+ values='num_bytes', maxdepth=4)
49
+ fig.update_traces(root_color="pink")
50
+ fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
51
+
52
+ st.plotly_chart(fig, use_container_width=True)
53
+
54
+