44 帕累托图

用途

柱状降序 + 累计曲线,快速找出前 20% 的关键因素。

示例(5 张)

44-1 线损影响因素的帕累托图

线损影响因素的帕累托图

44-2 配电故障原因的帕累托图

配电故障原因的帕累托图

44-3 谐波源贡献的帕累托图

谐波源贡献的帕累托图

44-4 储能投资构成的帕累托图

储能投资构成的帕累托图

44-5 停电损失的帕累托图

停电损失的帕累托图

代码

以下 5 个函数取自 code/第六批_组合图261107.py,直接调用即可出图。样式(宋体 + Times、10 磅、刻度朝内四边、留白自检)由 code/公共配置261107.py 的 setup_cn_style() 和 save() 统一提供,本节不再重复。

# 摘自 code/第六批_组合图261107.py

def pp_01():
    """线损影响因素的帕累托图。"""
    fig, ax = new_fig(left=0.19, bottom=0.25, right=0.87)
    items = ["三相不平衡", "无功不足", "导线细", "接户线长", "表计误差", "其他"]
    vals = np.array([186, 142, 108, 74, 42, 28])
    order = np.argsort(-vals)
    vals = vals[order]
    items = [items[i] for i in order]
    x = np.arange(len(items))
    ax.bar(x, vals, width=0.62, color=C1, edgecolor="0.35", linewidth=0.5,
           label="损耗量")
    ax.set_xticks(x)
    ax.set_xticklabels(items, rotation=18, ha="right", rotation_mode="anchor")
    ax.set_xlabel("影响因素")
    ax.set_ylabel("损耗 " + IT["P"] + " / kW")
    ax.set_ylim(0, 210)
    ax2 = ax.twinx()
    cum = np.cumsum(vals) / vals.sum() * 100
    ax2.plot(x, cum, marker="o", ms=3, color=C2, lw=1.0, label="累计占比")
    ax2.set_ylabel("累计占比 / %")
    ax2.set_ylim(0, 108)
    ax2.tick_params(direction="in", length=3, width=0.5)
    ax2.spines["right"].set_linewidth(0.5)
    h1, l1 = ax.get_legend_handles_labels()
    h2, l2 = ax2.get_legend_handles_labels()
    ax.legend(h1 + h2, l1 + l2, loc="center right", ncol=1, fontsize=FS - 1,
              framealpha=0.60, edgecolor="0.6")
    save(fig, "44_帕累托图", "44_帕累托图_线损影响因素")

def pp_02():
    """配电故障原因的帕累托图。"""
    fig, ax = new_fig(left=0.19, bottom=0.25, right=0.87)
    items = ["外力破坏", "设备老化", "雷击", "过负荷", "施工质量", "其他"]
    vals = np.array([126, 98, 64, 38, 26, 14])
    order = np.argsort(-vals)
    vals = vals[order]
    items = [items[i] for i in order]
    x = np.arange(len(items))
    ax.bar(x, vals, width=0.62, color=C3, edgecolor="0.35", linewidth=0.5,
           label="故障次数")
    ax.set_xticks(x)
    ax.set_xticklabels(items, rotation=18, ha="right", rotation_mode="anchor")
    ax.set_xlabel("故障原因")
    ax.set_ylabel("故障次数")
    ax.set_ylim(0, 142)
    ax2 = ax.twinx()
    cum = np.cumsum(vals) / vals.sum() * 100
    ax2.plot(x, cum, marker="s", ms=3, color=C2, lw=1.0, label="累计占比")
    ax2.set_ylabel("累计占比 / %")
    ax2.set_ylim(0, 108)
    ax2.tick_params(direction="in", length=3, width=0.5)
    ax2.spines["right"].set_linewidth(0.5)
    h1, l1 = ax.get_legend_handles_labels()
    h2, l2 = ax2.get_legend_handles_labels()
    ax.legend(h1 + h2, l1 + l2, loc="center right", ncol=1, fontsize=FS - 1,
              framealpha=0.60, edgecolor="0.6")
    save(fig, "44_帕累托图", "44_帕累托图_故障原因")

def pp_03():
    """谐波源贡献的帕累托图。"""
    fig, ax = new_fig(left=0.19, bottom=0.25, right=0.87)
    items = ["变频器", "整流装置", "UPS", "电弧炉", "荧光灯", "其他"]
    vals = np.array([34, 28, 16, 14, 8, 5])
    order = np.argsort(-vals)
    vals = vals[order]
    items = [items[i] for i in order]
    x = np.arange(len(items))
    ax.bar(x, vals, width=0.62, color=C1, edgecolor="0.35", linewidth=0.5,
           label="贡献占比")
    ax.set_xticks(x)
    ax.set_xticklabels(items, rotation=18, ha="right", rotation_mode="anchor")
    ax.set_xlabel("谐波源")
    ax.set_ylabel("贡献占比 / %")
    ax.set_ylim(0, 38)
    ax2 = ax.twinx()
    cum = np.cumsum(vals) / vals.sum() * 100
    ax2.plot(x, cum, marker="^", ms=3, color=C2, lw=1.0, label="累计占比")
    ax2.set_ylabel("累计占比 / %")
    ax2.set_ylim(0, 108)
    ax2.tick_params(direction="in", length=3, width=0.5)
    ax2.spines["right"].set_linewidth(0.5)
    h1, l1 = ax.get_legend_handles_labels()
    h2, l2 = ax2.get_legend_handles_labels()
    ax.legend(h1 + h2, l1 + l2, loc="center right", ncol=1, fontsize=FS - 1,
              framealpha=0.60, edgecolor="0.6")
    save(fig, "44_帕累托图", "44_帕累托图_谐波源贡献")

def pp_04():
    """储能投资构成的帕累托图。"""
    fig, ax = new_fig(left=0.19, bottom=0.25, right=0.87)
    items = ["电池", "PCS", "土建", "接入", "监控", "其他"]
    vals = np.array([210, 86, 58, 42, 24, 18])
    order = np.argsort(-vals)
    vals = vals[order]
    items = [items[i] for i in order]
    x = np.arange(len(items))
    ax.bar(x, vals, width=0.62, color=C5, edgecolor="0.35", linewidth=0.5,
           label="投资额")
    ax.set_xticks(x)
    ax.set_xticklabels(items, rotation=18, ha="right", rotation_mode="anchor")
    ax.set_xlabel("投资项")
    ax.set_ylabel("投资 / 万元")
    ax.set_ylim(0, 236)
    ax2 = ax.twinx()
    cum = np.cumsum(vals) / vals.sum() * 100
    ax2.plot(x, cum, marker="D", ms=3, color=C2, lw=1.0, label="累计占比")
    ax2.set_ylabel("累计占比 / %")
    ax2.set_ylim(0, 108)
    ax2.tick_params(direction="in", length=3, width=0.5)
    ax2.spines["right"].set_linewidth(0.5)
    h1, l1 = ax.get_legend_handles_labels()
    h2, l2 = ax2.get_legend_handles_labels()
    ax.legend(h1 + h2, l1 + l2, loc="center right", ncol=1, fontsize=FS - 1,
              framealpha=0.60, edgecolor="0.6")
    save(fig, "44_帕累托图", "44_帕累托图_储能投资构成")

def pp_05():
    """停电损失的帕累托图。"""
    fig, ax = new_fig(left=0.19, bottom=0.25, right=0.87)
    items = ["计划检修", "故障停电", "限电", "临时施工", "用户侧", "其他"]
    vals = np.array([186, 142, 88, 54, 32, 16])
    order = np.argsort(-vals)
    vals = vals[order]
    items = [items[i] for i in order]
    x = np.arange(len(items))
    ax.bar(x, vals, width=0.62, color=C3, edgecolor="0.35", linewidth=0.5,
           label="停电时户数")
    ax.set_xticks(x)
    ax.set_xticklabels(items, rotation=18, ha="right", rotation_mode="anchor")
    ax.set_xlabel("停电类型")
    ax.set_ylabel("停电时户数 / (户·h)")
    ax.set_ylim(0, 210)
    ax2 = ax.twinx()
    cum = np.cumsum(vals) / vals.sum() * 100
    ax2.plot(x, cum, marker="v", ms=3, color=C2, lw=1.0, label="累计占比")
    ax2.set_ylabel("累计占比 / %")
    ax2.set_ylim(0, 108)
    ax2.tick_params(direction="in", length=3, width=0.5)
    ax2.spines["right"].set_linewidth(0.5)
    h1, l1 = ax.get_legend_handles_labels()
    h2, l2 = ax2.get_legend_handles_labels()
    ax.legend(h1 + h2, l1 + l2, loc="center right", ncol=1, fontsize=FS - 1,
              framealpha=0.60, edgecolor="0.6")
    save(fig, "44_帕累托图", "44_帕累托图_停电损失")

说明

  • 图片尺寸 1181×944 px(100 mm × 80 mm @ 300 dpi),三维图为 1181×1122 px。
  • 图内不放标题,图题由本文件的二级/三级标题承担。
  • 数据为贴近广东实际量级的仿真算例,随机种子固定,重跑结果一致。
posted on 2026-11-08 00:12  小青蛙电气  阅读(3)  评论(0)    收藏  举报