06 累积分布 ecdfplot

这类图是什么

经验累积分布曲线,无需分箱。

看什么:直接读分位数与合格率,曲线与限值线求交即超标比例。

5 个案例

06-1 节点电压偏差的累积分布:直接读出合格率

节点电压偏差的累积分布:直接读出合格率

06-2 不同月份的负荷率累积分布:曲线越靠右上说明整体越高

不同月份的负荷率累积分布:曲线越靠右上说明整体越高

06-3 光伏预测误差的累积分布:读出 P90 分位

光伏预测误差的累积分布:读出 P90 分位

06-4 四种降损方案线损率的累积分布:曲线整体左移即方案更优

四种降损方案线损率的累积分布:曲线整体左移即方案更优

06-5 谐波含有率的累积分布:与限值线求交即超标比例

谐波含有率的累积分布:与限值线求交即超标比例

代码

5 个函数取自 code/第二批_分布图261107.py。关键约束:不调用 sns.set_theme(),否则 font.family 被改成 Arial,中文会变方框;版式由 code/公共配置261107.py 里的 setup_cn_style() 与 save() / save_grid() 统一接管。

# 摘自 code/第二批_分布图261107.py

def ec_01():
    """节点电压偏差的累积分布:直接读出合格率。"""
    fig, ax = new_fig()
    rng = np.random.default_rng(601)
    rows = []
    for grp, mu, sd in [("全部节点", 0.6, 2.5), ("末端节点", 1.8, 1.6)]:
        rows.append(pd.DataFrame({"偏差": rng.normal(mu, sd, 1200), "范围": grp}))
    df = pd.concat(rows, ignore_index=True)
    sns.ecdfplot(data=df, x="偏差", hue="范围", palette=[C5, C3], lw=1.1, ax=ax)
    ax.axvline(7, color=C2, lw=0.8, ls="--")
    ax.axvline(-7, color=C2, lw=0.8, ls=":")
    ax.set_xlabel("电压偏差 / %")
    ax.set_ylabel("累积概率")
    ax.set_xlim(-10, 12)
    ax.set_ylim(0, 1.05)
    legend_in(ax, "upper left")
    save(fig, "06_累积分布", "06_累积分布_节点电压偏差")

def ec_02():
    """不同月份的负荷率累积分布:曲线越靠右上说明整体越高。"""
    fig, ax = new_fig()
    rng = np.random.default_rng(602)
    rows = []
    for m, mu in [("1 月", 0.71), ("7 月", 0.84), ("10 月", 0.77)]:
        rows.append(pd.DataFrame({"负荷率": rng.normal(mu, 0.05, 800), "月份": m}))
    df = pd.concat(rows, ignore_index=True)
    sns.ecdfplot(data=df, x="负荷率", hue="月份", palette=PALETTE3, lw=1.1, ax=ax)
    ax.set_xlabel("日负荷率")
    ax.set_ylabel("累积概率")
    ax.set_xlim(0.50, 1.02)
    ax.set_ylim(0, 1.05)
    legend_in(ax, "upper left")
    save(fig, "06_累积分布", "06_累积分布_各月负荷率")

def ec_03():
    """光伏预测误差的累积分布:读出 P90 分位。"""
    fig, ax = new_fig()
    rng = np.random.default_rng(603)
    e = rng.laplace(0, 3.8, 2000)
    sns.ecdfplot(x=np.abs(e), color=C1, lw=1.2, ax=ax)
    q90 = np.quantile(np.abs(e), 0.90)
    ax.axvline(q90, color=C2, lw=0.8, ls="--")
    ax.set_xlabel("预测误差绝对值 / %")
    ax.set_ylabel("累积概率")
    ax.set_xlim(0, 16)
    ax.set_ylim(0, 1.05)
    save(fig, "06_累积分布", "06_累积分布_光伏预测误差")

def ec_04():
    """四种降损方案线损率的累积分布:曲线整体左移即方案更优。"""
    fig, ax = new_fig()
    rng = np.random.default_rng(604)
    rows = []
    for plan, mu, sd in [("原状", 4.62, 0.30), ("方案一", 3.71, 0.26),
                         ("方案二", 3.24, 0.22), ("方案三", 2.86, 0.19)]:
        rows.append(pd.DataFrame({"线损率": rng.normal(mu, sd, 700), "方案": plan}))
    df = pd.concat(rows, ignore_index=True)
    sns.ecdfplot(data=df, x="线损率", hue="方案", palette=PALETTE4, lw=1.1, ax=ax)
    ax.set_xlabel("年线损率 / %")
    ax.set_ylabel("累积概率")
    ax.set_xlim(1.8, 5.6)
    ax.set_ylim(0, 1.05)
    legend_in(ax, "upper left")
    save(fig, "06_累积分布", "06_累积分布_降损方案线损率")

def ec_05():
    """谐波含有率的累积分布:与限值线求交即超标比例。"""
    fig, ax = new_fig()
    rng = np.random.default_rng(605)
    rows = []
    for pt, k, th in [("监测点 A", 2.4, 4.0), ("监测点 B", 2.8, 3.2)]:
        rows.append(pd.DataFrame({"含有率": rng.gamma(k, th, 900), "测点": pt}))
    df = pd.concat(rows, ignore_index=True)
    sns.ecdfplot(data=df, x="含有率", hue="测点", palette=[C5, C3], lw=1.1, ax=ax)
    ax.axvline(4.0, color=C2, lw=0.8, ls="--")
    ax.set_xlabel("谐波电压含有率 / %")
    ax.set_ylabel("累积概率")
    ax.set_xlim(0, 24)
    ax.set_ylim(0, 1.05)
    legend_in(ax, "lower right")
    save(fig, "06_累积分布", "06_累积分布_谐波含有率")

说明

  • axes 级图 1181×944 px;figure 级多轴图按内容取 1100~1470 px 宽。
  • 图内不放标题,图题由本文件的标题承担。
  • 数据为 10 kV 配网、380 V 低压、50 Hz 量级的仿真算例,随机种子固定。
posted on 2026-11-08 00:13  小青蛙电气  阅读(2)  评论(0)    收藏  举报