def add_cpi_page(canvas_para, length): """ 函数功能:增加CPI页 :param canvas_para: :return: """ c = canvas_para cpi_df = ts.get_cpi() cpi_df['month'] = cpi_df.apply(lambda x: stdMonthDate(x['month']), axis=1) cpi_df = cpi_df.sort_values( by='month', ascending=False).head(length).sort_values(by='month', ascending=True) cpi = extract_point_from_df_date_x(df_origin=cpi_df, date_col='month', y_col='cpi', timeAxis='month') gdp_pull_drawing = gen_lp_drawing([tuple(cpi)], data_note=['CPI增长率'], time_axis='month') renderPDF.draw(drawing=gdp_pull_drawing, canvas=c, x=10, y=letter[1] * 0.6) c.showPage() return c
def add_ppi_page(canvas_para, length): """ 函数功能:工业品出厂价格指数 :param canvas_para: :return: """ c = canvas_para ppi_df = ts.get_ppi() ppi_df['month'] = ppi_df.apply(lambda x:stdMonthDate(x['month']), axis=1) ppi_df = ppi_df.sort_values(by='month',ascending=False).head(length).sort_values(by='month',ascending=True) ppiip = extract_point_from_df_date_x(df_origin=ppi_df, date_col='month', y_col='ppiip', timeAxis='month') ppi = extract_point_from_df_date_x(df_origin=ppi_df, date_col='month', y_col='ppi', timeAxis='month') qm = extract_point_from_df_date_x(df_origin=ppi_df, date_col='month', y_col='qm', timeAxis='month') rmi = extract_point_from_df_date_x(df_origin=ppi_df, date_col='month', y_col='rmi', timeAxis='month') pi = extract_point_from_df_date_x(df_origin=ppi_df, date_col='month', y_col='pi', timeAxis='month') ppi_industry_drawing = gen_lp_drawing([tuple(ppiip), tuple(ppi), tuple(qm), tuple(rmi), tuple(pi)], data_note=['工业品出厂价格指数', '生产资料价格指数', '采掘工业价格指数', '原材料工业价格指数', '加工工业价格指数'], time_axis='month') renderPDF.draw(drawing=ppi_industry_drawing, canvas=c, x=10, y=letter[1] * 0.6) cg = extract_point_from_df_date_x(df_origin=ppi_df, date_col='month', y_col='cg', timeAxis='month') food = extract_point_from_df_date_x(df_origin=ppi_df, date_col='month', y_col='food', timeAxis='month') clothing = extract_point_from_df_date_x(df_origin=ppi_df, date_col='month', y_col='clothing', timeAxis='month') roeu = extract_point_from_df_date_x(df_origin=ppi_df, date_col='month', y_col='roeu', timeAxis='month') dcg = extract_point_from_df_date_x(df_origin=ppi_df, date_col='month', y_col='dcg', timeAxis='month') ppi_life_drawing = gen_lp_drawing([tuple(cg), tuple(food), tuple(clothing), tuple(roeu), tuple(dcg)], data_note=['生活资料价格指数', '食品类价格指数', '衣着类价格指数', '一般日用品价格指数', '耐用消费品价格指数'], time_axis='month') renderPDF.draw(drawing=ppi_life_drawing, canvas=c, x=10, y=letter[1] * 0.2) c.showPage() return c
# encoding = utf-8 from Config.GlobalSetting import * from SDK.AboutTimeSub import stdMonthDate ppi_df = ts.get_ppi() # trick to get the axes fig, ax = plt.subplots() std_date = list(map(lambda x: stdMonthDate(x), ppi_df['month'])) # plot data ax.plot(std_date, ppi_df['ppiip'], 'go--', label=U'工业品出厂') ax.plot(std_date, ppi_df['ppi'], 'b*--', label=U'生产资料') ax.plot(std_date, ppi_df['qm'], 'cv--', label=U'采掘工业') ax.plot(std_date, ppi_df['rmi'], 'g*--', label=U'原材料工业') ax.plot(std_date, ppi_df['pi'], 'k*--', label=U'加工工业') ax.plot(std_date, ppi_df['cg'], 'm*--', label=U'生活资料') ax.plot(std_date, ppi_df['food'], 'r*--', label=U'食品类') ax.plot(std_date, ppi_df['clothing'], 'y^-', label=U'衣着类') ax.plot(std_date, ppi_df['roeu'], 'y*--', label=U'一般日用品') ax.plot(std_date, ppi_df['dcg'], 'y*:', label=U'耐用消费品') xticklabels = list(std_date) xticklabels.reverse() ax.set_xticklabels(xticklabels, rotation=90) ax.set_title('各种价格指数') ax.legend(loc='best') plt.show()