Skip to content

Commit 2dc0bac

Browse files
authored
Merge pull request #86 from brain-image-library/50-new-metric-request-treemap-for-projects
Update get.py
2 parents 76f0a0a + 9317f72 commit 2dc0bac

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

braininventory/get.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,3 +1352,28 @@ def report():
13521352
get_projects_treemap(df)
13531353

13541354
return report
1355+
1356+
def create_tree_map(frequency_dict, width, height):
1357+
"""
1358+
Get a treemap of projects
1359+
1360+
Input parameter: dictionary
1361+
Output: treemap image
1362+
"""
1363+
labels = list(frequency_dict.keys())
1364+
values = list(frequency_dict.values())
1365+
1366+
fig = go.Figure(go.Treemap(
1367+
labels=labels,
1368+
parents=[''] * len(labels),
1369+
values=values,
1370+
textinfo='label+value'
1371+
))
1372+
1373+
fig.update_layout(title='Projects', width=width, height=height)
1374+
1375+
today = date.today()
1376+
output_path = f'treemap-{today.strftime("%Y%m%d")}.png'
1377+
fig.write_image(output_path)
1378+
fig.show()
1379+

0 commit comments

Comments
 (0)