import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
papers = pd.read_csv('D:/研究生/实体调研/papers.csv')
conferences = ['ACL', 'NAACL', 'EMNLP']
years = [2020, 2021]
conference_papers = pd.DataFrame()
def print_plt(data, title):
labels = ["{}".format(category) for category in data['Category'].unique()]
table = pd.DataFrame(columns=['label', 'paper_num', 'cutation_num'])
for category in labels:
citation = data[data['Category'] == category]
row = pd.DataFrame({'label': [category], 'paper_num': len(citation),
'cutation_num': citation['Citations'].sum()})
table = pd.concat([table, row], axis=0)
fig, ax = plt.subplots()
plt.rcParams['font.sans-serif'] = ['SimHei']
table.sort_values(by=[ 'paper_num', 'cutation_num'], axis=0,
ascending=[False, False], inplace=True)
ax.bar(np.arange(len(table['paper_num'])), table['paper_num'],
width=0.4, tick_label=labels, label="论文数")
ax.bar(np.arange(len(table['cutation_num'])) + 0.4,
table['cutation_num'], width=0.4, color=['darkorange'],
tick_label=labels, label="引用数和")
plt.title(title)
plt.xticks(rotation=90)
plt.subplots_adjust(bottom=0.30)
plt.legend()
plt.show()
print_plt(papers, "2020-2021")
for i in range(3):
for j in range(2):
conference_papers = papers[(papers.Conference == conferences[i]) &
(papers.Year == years[j])]
if not conference_papers.empty:
print_plt(conference_papers, conferences[i] + ' ' + str(years[j]))
|