35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
|
|
import pandas as pd
|
||
|
|
import numpy as np
|
||
|
|
from pathlib import Path
|
||
|
|
from loguru import logger
|
||
|
|
|
||
|
|
def generate(output_dir):
|
||
|
|
logger.info("开始生成CPI/PPI通胀图表")
|
||
|
|
|
||
|
|
months = ['1月', '2月', '3月', '4月', '5月', '6月']
|
||
|
|
cpi = [0.7, 0.8, 0.9, 1.0, np.random.uniform(0.8, 1.2), np.random.uniform(0.8, 1.2)]
|
||
|
|
ppi = [-2.5, -2.3, -2.0, -1.8, np.random.uniform(-2.5, -1.5), np.random.uniform(-2.5, -1.5)]
|
||
|
|
|
||
|
|
data = pd.DataFrame({
|
||
|
|
'月份': months,
|
||
|
|
'CPI(%)': [round(x, 2) for x in cpi],
|
||
|
|
'PPI(%)': [round(x, 2) for x in ppi]
|
||
|
|
})
|
||
|
|
data = data.set_index('月份')
|
||
|
|
|
||
|
|
from dynamic_generator import DynamicContentGenerator
|
||
|
|
generator = DynamicContentGenerator()
|
||
|
|
output_path = generator.generate_chart_plotly(
|
||
|
|
data,
|
||
|
|
title='CPI与PPI走势',
|
||
|
|
x_label='月份',
|
||
|
|
y_label='同比 (%)',
|
||
|
|
filename='inflation_chart.png',
|
||
|
|
kind='line'
|
||
|
|
)
|
||
|
|
|
||
|
|
return output_path
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
generate(Path.cwd())
|