Skip to content

Commit 2d7d22b

Browse files
authored
Visualization of general modalities
1 parent 84f48d7 commit 2d7d22b

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
@@ -184,3 +184,28 @@ def report():
184184
get_projects_treemap(df)
185185

186186
return report
187+
188+
# Creates a segmented bar graph that shows the proportion of general modalities over the years.
189+
# Dropped the null values (no creation dates)
190+
df[~df['creation_date'].isnull()]
191+
df['dates'] = pd.to_datetime(df['creation_date'])
192+
df['year'] = df['dates'].dt.year
193+
df = df.dropna(subset=['year'])
194+
df['year'] = df['year'].astype(int)
195+
grouped = df.groupby(df['dates'].dt.year)
196+
197+
import matplotlib.pyplot as plt
198+
199+
grouped = df.groupby(['year', 'generalmodality']).size().reset_index(name='count')
200+
201+
pivot_df = grouped.pivot(index='year', columns='generalmodality', values='count').fillna(0)
202+
203+
pivot_df.plot(kind='bar', stacked=True)
204+
205+
plt.title('General Modalities')
206+
plt.ylabel('Number of Datasets')
207+
plt.xlabel('Year')
208+
plt.xticks(rotation=45)
209+
plt.tight_layout()
210+
211+
plt.show()

0 commit comments

Comments
 (0)