|
@@ -122,25 +122,66 @@ def put_analysis_report_to_html(args, df_clean, df_predict, df_accuracy):
|
|
|
|
|
|
# -------------------- 6.实测气象与预测气象趋势曲线 --------------------
|
|
# -------------------- 6.实测气象与预测气象趋势曲线 --------------------
|
|
|
|
|
|
- # 生成折线图(以 C_GLOBALR 和 NWP预测总辐射 为例)
|
|
|
|
- y_env = [col_x_env]+ col_x_pre
|
|
|
|
- fig_line = px.line(df_clean[(df_clean[col_time]>=df_predict[col_time].min())&(df_clean[col_time]<=df_predict[col_time].max())], x=col_time, y=y_env, markers=True)
|
|
|
|
- # 自定义趋势图布局
|
|
|
|
|
|
+ # # 生成折线图(以 C_GLOBALR 和 NWP预测总辐射 为例)实际功率
|
|
|
|
+ # y_env = [label,col_x_env]+ col_x_pre
|
|
|
|
+ # fig_line = px.line(df_clean, x=col_time, y=y_env, markers=True)
|
|
|
|
+ # # fig_line = px.line(df_clean[(df_clean[col_time] >= df_predict[col_time].min()) & (
|
|
|
|
+ # # df_clean[col_time] <= df_predict[col_time].max())], x=col_time, y=y_env, markers=True)
|
|
|
|
+ # # 自定义趋势图布局
|
|
|
|
+ # fig_line.update_layout(
|
|
|
|
+ # template='seaborn',
|
|
|
|
+ # # title=dict(text=f"{col_x_env}与{col_x_pre}趋势曲线",
|
|
|
|
+ # # x=0.5, font=dict(size=24, color='darkblue')),
|
|
|
|
+ # plot_bgcolor='rgba(255, 255, 255, 0.8)', # 改为白色背景
|
|
|
|
+ # xaxis=dict(
|
|
|
|
+ # showgrid=True,
|
|
|
|
+ # gridcolor='rgba(200, 200, 200, 0.5)', # 网格线颜色
|
|
|
|
+ # rangeslider=dict(visible=True), # 显示滚动条
|
|
|
|
+ # rangeselector=dict(visible=True) # 显示预设的时间范围选择器
|
|
|
|
+ # ),
|
|
|
|
+ # yaxis=dict(showgrid=True, gridcolor='rgba(200, 200, 200, 0.5)'),
|
|
|
|
+ # legend=dict(x=0.01, y=0.99, bgcolor='rgba(255, 255, 255, 0.7)', bordercolor='black', borderwidth=1)
|
|
|
|
+ # )
|
|
|
|
+ #
|
|
|
|
+ # # 将折线图保存为 HTML 片段
|
|
|
|
+ # env_pre_html = pio.to_html(fig_line, full_html=False)
|
|
|
|
+ # 创建折线图(label 单独一个纵轴, [col_x_env] + col_x_pre 一个纵轴)
|
|
|
|
+ fig_line = px.line(df_clean, x=col_time, y=[label] + [col_x_env] + col_x_pre, markers=True)
|
|
|
|
+
|
|
|
|
+ # 修改布局,添加双轴设置
|
|
fig_line.update_layout(
|
|
fig_line.update_layout(
|
|
template='seaborn',
|
|
template='seaborn',
|
|
- # title=dict(text=f"{col_x_env}与{col_x_pre}趋势曲线",
|
|
|
|
- # x=0.5, font=dict(size=24, color='darkblue')),
|
|
|
|
- plot_bgcolor='rgba(255, 255, 255, 0.8)', # 改为白色背景
|
|
|
|
|
|
+ plot_bgcolor='rgba(255, 255, 255, 0.8)', # 设置白色背景
|
|
xaxis=dict(
|
|
xaxis=dict(
|
|
showgrid=True,
|
|
showgrid=True,
|
|
gridcolor='rgba(200, 200, 200, 0.5)', # 网格线颜色
|
|
gridcolor='rgba(200, 200, 200, 0.5)', # 网格线颜色
|
|
rangeslider=dict(visible=True), # 显示滚动条
|
|
rangeslider=dict(visible=True), # 显示滚动条
|
|
rangeselector=dict(visible=True) # 显示预设的时间范围选择器
|
|
rangeselector=dict(visible=True) # 显示预设的时间范围选择器
|
|
),
|
|
),
|
|
- yaxis=dict(showgrid=True, gridcolor='rgba(200, 200, 200, 0.5)'),
|
|
|
|
- legend=dict(x=0.01, y=0.99, bgcolor='rgba(255, 255, 255, 0.7)', bordercolor='black', borderwidth=1)
|
|
|
|
|
|
+ yaxis=dict(
|
|
|
|
+ title="实际功率", # 主纵轴用于 label
|
|
|
|
+ showgrid=True,
|
|
|
|
+ gridcolor='rgba(200, 200, 200, 0.5)'
|
|
|
|
+ ),
|
|
|
|
+ yaxis2=dict(
|
|
|
|
+ title="环境数据", # 第二纵轴用于 [col_x_env] + col_x_pre
|
|
|
|
+ overlaying='y', # 与主纵轴叠加
|
|
|
|
+ side='right', # 放置在右侧
|
|
|
|
+ showgrid=False # 不显示网格线
|
|
|
|
+ ),
|
|
|
|
+ legend=dict(
|
|
|
|
+ x=0.01,
|
|
|
|
+ y=0.99,
|
|
|
|
+ bgcolor='rgba(255, 255, 255, 0.7)',
|
|
|
|
+ bordercolor='black',
|
|
|
|
+ borderwidth=1
|
|
|
|
+ )
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+ # 更新每个曲线的 y 轴对应性
|
|
|
|
+ for i, col in enumerate([label] + [col_x_env] + col_x_pre):
|
|
|
|
+ fig_line.data[i].update(yaxis='y' if col == label else 'y2')
|
|
|
|
+
|
|
# 将折线图保存为 HTML 片段
|
|
# 将折线图保存为 HTML 片段
|
|
env_pre_html = pio.to_html(fig_line, full_html=False)
|
|
env_pre_html = pio.to_html(fig_line, full_html=False)
|
|
|
|
|