各projectの被リンク数histogram
https://gyazo.com/353f1d797d24876da3c89a49d1cbb0d5https://gyazo.com/159dcfb1f171df874adba12dce6b3e58
https://gyazo.com/edcbc6ffc99589a41a0ffce645b47844https://gyazo.com/c849d02bd6476f6c3cdc283037633a83
https://gyazo.com/b566d14014f35d98cf27386ca519f20d
横軸のメモリ幅を統一したほうが比較しやすい
使用したscript
code:plot.py
from __future__ import print_function
from __future__ import unicode_literals
import requests
import matplotlib.pyplot as plt
import matplotlib as mpl
import collections
import argparse
mpl.use("Agg")
# matplotlibで日本語を使えるようにする
def main(project):
pages = []
response = requests.get(
followingId = response.headers.get('X-Following-Id')
pages += response.json()
while followingId == None:
response = requests.get(
followingId = response.headers.get('X-Following-Id')
pages += response.json()
pass
print('Finish loading all data')
# 取得結果の確認
for page in pages:
print('Calculating the number of back links...')
temp = []
for page in pages:
linkNum = collections.Counter(temp);
print(linkNum)
print('finished.')
print('Plotting a histogram...')
n, bins, patches = plt.hist(linkNum.values(), bins=max(linkNum.values())-min(linkNum.values()), log=True)
[plt.text((binsi+1+binsi)/2, ni, int(ni), horizontalalignment='center') for i in range(len(bins)-1)]
ax=plt.gca()
ax.set_title(project)
ax.set_xlabel('被リンク数')
ax.set_ylabel('ページ数')
plt.savefig(f'{project}.png')
print('finished.')
if __name__ == "__main__":
# Command line argumentsの設定
parser = argparse.ArgumentParser(
description="指定したscrapbox projectの被リンク数のhistogramを作成するscript")
parser.add_argument('project',help='分析したいscrapbox project name')
# argumentsを解析する
args = parser.parse_args()
project = args.project
# main loop
main(project)