Skip to content

Instantly share code, notes, and snippets.

@sdres
Last active February 4, 2022 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sdres/1fa61f3cd7ee46fc06aa3f28d15c9b66 to your computer and use it in GitHub Desktop.
Save sdres/1fa61f3cd7ee46fc06aa3f28d15c9b66 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import pandas as pd
import matplotlib.pyplot as plt
from collections import Counter
sheet_id = '1REpJa7gl4i7Dxbw-JHcF-dhne3UFgqwkKE_If1nXrmY'
sheet_name = 'Included'
url = f'https://docs.google.com/spreadsheets/d/{sheet_id}/gviz/tq?tqx=out:csv&sheet={sheet_name}'
data = pd.read_csv(url).sort_values(by=['Count','First Author'])
# Pie chart
plt.style.use('fivethirtyeight')
backgroundCounter = Counter()
for i, row in data.iterrows():
backgroundCounter.update([row['Background']])
backgrounds = []
counts = []
for key in backgroundCounter:
if key == 'unknown':
continue
backgrounds.append(key)
counts.append(backgroundCounter[key])
pieData = pd.DataFrame({'backgrounds':backgrounds, 'counts':counts})
pieData = pieData.sort_values(by=['counts'], ascending=False)
# colors generated here:
# https://learnui.design/tools/data-color-picker.html#palette
colors = ['#003f5c','#374c80','#7a5195','#bc5090','#ef5675','#ff764a','#ffa600']
plt.pie(pieData['counts'], labels=pieData['backgrounds'], counterclock=False,colors=colors,startangle=-270)
plt.title("Backgrounds of First Authors of VASO Layer-fMRI Papers in Humans")
plt.savefig('vasoAuthorsPie.png',bbox_inches='tight')
plt.show()
# horizontal bar chart
plt.barh(data['First Author'], data['Count'], color='#003f5c')
plt.title('Number of First Author Human Layer fMRI Papers using VASO')
plt.yticks(fontsize=10)
plt.tight_layout()
plt.savefig('vasoAuthorsBar.png',bbox_inches='tight')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment