论文调研中用到的dataframe及plt

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]))

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值