Skip to content

Commit

Permalink
Merge pull request #44 from C2DH/gradient
Browse files Browse the repository at this point in the history
Update for the colors used for the statictics charts
  • Loading branch information
memerchik authored Sep 19, 2024
2 parents 6f699d1 + 452e9a0 commit 94090ea
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions jdh_statistics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
"import requests\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"from matplotlib import cm\n",
"import numpy as np\n",
"\n",
"\n",
"\n",
"# API URL\n",
Expand Down Expand Up @@ -73,8 +76,8 @@
" articles_per_year = df['publication_year'].value_counts().sort_index()\n",
"\n",
" # Plot the data\n",
" my_colors = [(x/10.0, x/20.0, 0.75) for x in range(len(articles_per_year))]\n",
" articles_per_year.plot(kind='bar', xlabel='Year', ylabel='Number of Articles', title='Articles Published per Year', color=my_colors)\n",
" colors = cm.inferno_r(np.linspace(.4, .8, 5))\n",
" articles_per_year.plot(kind='bar', xlabel='Year', ylabel='Number of Articles', title='Articles Published per Year', color=colors)\n",
" # Set y-axis ticks to integers only\n",
" plt.yticks(range(int(articles_per_year.max()) + 1))\n",
"\n",
Expand Down Expand Up @@ -155,7 +158,8 @@
" abstracts_per_year = df['submitted_date'].value_counts().sort_index()\n",
"\n",
" # Plot the data as a line plot\n",
" abstracts_per_year.plot(kind='line', marker='o', xlabel='Year', ylabel='Number of Abstracts', title='Abstracts submitted per Year')\n",
" colors = cm.inferno_r(np.linspace(.4, .8, 4))\n",
" abstracts_per_year.plot(kind='line', marker='o', xlabel='Year', ylabel='Number of Abstracts', title='Abstracts submitted per Year', color=colors)\n",
"\n",
" plt.show()\n",
"\n",
Expand Down Expand Up @@ -239,7 +243,8 @@
"pivot_table = pd.pivot_table(df, values='status', index='submitted_date', columns='callpaper', aggfunc='count', fill_value=0)\n",
"\n",
"# Plot the data as a line plot\n",
"ax = pivot_table.plot(kind='line', marker='o', xlabel='Year', ylabel='Number of Abstracts', title='Abstracts submitted per Year by Callpaper Type')\n",
"colors = cm.inferno_r(np.linspace(.4, .8, 4))\n",
"ax = pivot_table.plot(kind='line', marker='o', xlabel='Year', ylabel='Number of Abstracts', title='Abstracts submitted per Year by Callpaper Type', color=colors)\n",
"\n",
"# Get the handles and labels of the current axes\n",
"handles, labels = ax.get_legend_handles_labels()\n",
Expand Down Expand Up @@ -348,8 +353,9 @@
"status_counts = df['status'].value_counts()\n",
"\n",
"# Plot a pie chart\n",
"colors = cm.inferno_r(np.linspace(.4, .8, 3))\n",
"plt.figure(figsize=(8, 8)) # Set the figure size\n",
"plt.pie(status_counts, labels=status_counts.index, autopct='%1.1f%%', startangle=140)\n",
"plt.pie(status_counts, labels=status_counts.index, autopct='%1.1f%%', startangle=140, colors=colors)\n",
"plt.title('Article Status Distribution')\n",
"plt.show()"
]
Expand Down Expand Up @@ -377,7 +383,8 @@
"grouped_data = df.groupby(['issue_title', 'status']).size().unstack(fill_value=0)\n",
"\n",
"# Plot a stacked bar chart\n",
"grouped_data.plot(kind='bar', stacked=True, figsize=(10, 7))\n",
"colors = cm.inferno_r(np.linspace(.4, .8, 4))\n",
"grouped_data.plot(kind='bar', stacked=True, figsize=(10, 7), color=colors)\n",
"plt.title('Number of Articles by Status and Issue')\n",
"plt.xlabel('Issue Title')\n",
"plt.ylabel('Number of Articles')\n",
Expand Down Expand Up @@ -512,7 +519,8 @@
"issues_per_year = df['year'].value_counts().sort_index()\n",
"\n",
"# Plotting\n",
"issues_per_year.plot(kind='bar')\n",
"colors = cm.inferno_r(np.linspace(.4, .8, 4))\n",
"issues_per_year.plot(kind='bar', color=colors)\n",
"plt.title('Number of Issues Closed per Year')\n",
"plt.xlabel('Year')\n",
"plt.ylabel('Number of Issues Closed')\n",
Expand Down

0 comments on commit 94090ea

Please sign in to comment.