Skip to content

Commit b0f67f0

Browse files
authored
Merge pull request #60 from brain-image-library/59-general-modality-plot
General Modality Bar Graph
2 parents ff151af + f6dfec5 commit b0f67f0

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

braininventory/get.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22
from datetime import date
3-
3+
import urllib.request
4+
import matplotlib.pyplot as plt
45
import humanize
56
import matplotlib.pyplot as plt
67
import pandas as pd
@@ -14,6 +15,25 @@
1415
import squarify
1516

1617

18+
def __get_general_modality_plot(df):
19+
modality_counts = df["generalmodality"].value_counts()
20+
21+
plt.figure(figsize=(10, 6))
22+
color = plt.cm.tab20c.colors
23+
24+
ax = modality_counts.plot(kind="bar", color=color, edgecolor="black")
25+
plt.xlabel("General Modality", fontsize=12)
26+
plt.ylabel("Frequency", fontsize=12)
27+
plt.title("Frequency of General Modality", fontsize=14)
28+
plt.xticks(rotation=45, ha="right", fontsize=10)
29+
plt.yticks(fontsize=10)
30+
31+
plt.tight_layout()
32+
33+
filename = f'general-modality-{datetime.now().strftime("%Y%m%d")}.png'
34+
plt.savefig(filename)
35+
36+
1737
def get_random_sample(df):
1838
"""
1939
Returns a random sample from the dataframe from a dataset with non-zero score.
@@ -826,7 +846,7 @@ def get_projects_treemap(df):
826846
squarify.plot(sizes_list)
827847

828848
filename = f'treemap-projects-{datetime.now().strftime("%Y%m%d")}.png'
829-
plt.savefig("path/to/save/plot.png")
849+
plt.savefig(filename)
830850

831851

832852
def __get__percentage_of_metadata_version_1(df):

0 commit comments

Comments
 (0)