File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 2020 ],
2121 python_requires = ">=3.6" ,
2222)
23+ import pandas as pd
24+ import urllib .request
25+
26+ url = 'https://download.brainimagelibrary.org/inventory/daily/reports/today.json'
27+ file_path , _ = urllib .request .urlretrieve (url )
28+ df = pd .read_json (file_path )
29+
30+ #get affiliations
31+ affiliations = df ['genotype' ].value_counts ().to_dict ()
32+ affiliations
33+
34+ !pip install kaleido
35+
36+ import plotly .graph_objects as go
37+ from datetime import date
38+
39+ def create_tree_map (frequency_dict ):
40+ labels = list (frequency_dict .keys ())
41+ values = list (frequency_dict .values ())
42+
43+ fig = go .Figure (go .Treemap (
44+ labels = labels ,
45+ parents = ['' ] * len (labels ),
46+ values = values ,
47+ textinfo = 'label+value'
48+ ))
49+
50+ fig .update_layout (title = 'Genotypes' )
51+
52+ today = date .today ()
53+ output_path = f'treemap-{ today .strftime ("%Y%m%d" )} .png'
54+ fig .write_image (output_path )
55+ fig .show ()
56+
57+ create_tree_map (affiliations )
You can’t perform that action at this time.
0 commit comments