Skip to content

Commit

Permalink
#30 emojis
Browse files Browse the repository at this point in the history
  • Loading branch information
karacolada committed Aug 2, 2023
1 parent e677008 commit 9daffd0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions analysis/overall.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,28 @@ def plot_license_type(contents, ax):
contents.license.isin(permissive_licenses), "permissive", np.where(
contents.license == "None", "None", np.where(
contents.license == "other", "unknown", "non-permissive")))
contents.license_type.value_counts().plot(
contents.license_type.value_counts().sort_index().plot(
kind='bar',
ax=ax,
xlabel="license type",
ylabel="count"
ylabel="repository count"
)

def plot_emojis(contents, ax):
counts, bins = np.histogram(contents.readme_emojis, [0, 1, 2, 5, 10, contents.readme_emojis.max()])
binlabels = [f"[{bins[i]} - {bins[i+1]})" for i in range(len(bins)-2)]
binlabels += [f"[{bins[-2]} - {bins[-1]}]"]
ax.bar(binlabels, counts)
ax.set(xlabel="number of emojis in README", ylabel="repository count")

def main(data_dir, verbose):
info(verbose, "Loading data...")
contents = pd.read_csv(os.path.join(data_dir, "contents.csv"), index_col=0)

info(verbose, "Plotting...")
fig, axs = plt.subplots(ncols=2, figsize=(8, 4))
plot_license_type(contents, axs[0])
plot_emojis(contents, axs[1])
plt.savefig(os.path.join(data_dir, "overall.png"), bbox_inches="tight")

if __name__=="__main__":
Expand Down

0 comments on commit 9daffd0

Please sign in to comment.