43 坡形图
用途
两三个时点之间多条指标的连线,看谁升谁降。
示例(5 张)
43-1 改造前后四项指标的坡形图

43-2 两种方案六项指标的坡形图

43-3 峰谷电价调整前后的坡形图

43-4 各节点电压治理前后的坡形图

43-5 年度关键指标的坡形图

代码
以下 5 个函数取自 code/第六批_组合图261107.py,直接调用即可出图。样式(宋体 + Times、10 磅、刻度朝内四边、留白自检)由 code/公共配置261107.py 的 setup_cn_style() 和 save() 统一提供,本节不再重复。
# 摘自 code/第六批_组合图261107.py
def sl_01():
"""改造前后四项指标的坡形图。"""
fig, ax = new_fig(left=0.20)
cats = ["线损率", "负载率", "电压偏差", "功率因数"]
before = np.array([4.62, 86.0, 6.2, 0.86])
after = np.array([3.24, 72.0, 3.1, 0.93])
x = [0, 1]
for i in range(len(cats)):
ax.plot(x, [before[i] / before.max(), after[i] / after.max()],
marker=MARKERS[i], ms=4, color=COLORS[i], lw=1.0)
ax.text(-0.06, before[i] / before.max(), f"{before[i]:g}", ha="right",
va="center", fontsize=FS - 2, color=COLORS[i])
ax.text(1.06, after[i] / after.max(), f"{after[i]:g}", ha="left",
va="center", fontsize=FS - 2, color=COLORS[i])
ax.set_xticks([0, 1])
ax.set_xticklabels(["改造前", "改造后"])
ax.set_xlim(-0.35, 1.35)
ax.set_ylim(0, 1.08)
ax.set_xlabel("时间节点")
ax.set_ylabel("归一化指标值")
legend(ax, "lower left", ncol=2, fontsize=FS - 2)
save(fig, "43_坡形图", "43_坡形图_改造前后指标")
def sl_02():
"""两种方案六项指标的坡形图。"""
fig, ax = new_fig(left=0.20)
cats = ["投资", "线损", "效率", "可靠性", "运维", "环保"]
a = np.array([318, 3.24, 0.92, 99.6, 112, 8.6])
b = np.array([402, 2.86, 0.95, 99.8, 82, 9.2])
a_n = a / np.maximum(a, b)
b_n = b / np.maximum(a, b)
x = [0, 1]
for i in range(len(cats)):
ax.plot(x, [a_n[i], b_n[i]], marker=MARKERS[i % 4], ms=4,
color=COLORS[i % 4], lw=1.0)
ax.set_xticks([0, 1])
ax.set_xticklabels(["方案二", "方案三"])
ax.set_xlim(-0.25, 1.25)
ax.set_ylim(0.5, 1.06)
ax.set_xlabel("对比方案")
ax.set_ylabel("归一化指标值")
save(fig, "43_坡形图", "43_坡形图_两方案对比")
def sl_03():
"""峰谷电价调整前后的坡形图。"""
fig, ax = new_fig(left=0.20)
cats = ["尖峰", "高峰", "平段", "低谷"]
before = np.array([0.92, 0.86, 0.58, 0.32])
after = np.array([1.06, 0.94, 0.58, 0.24])
x = [0, 1]
for i in range(len(cats)):
ax.plot(x, [before[i], after[i]], marker=MARKERS[i % 4], ms=4,
color=COLORS[i % 4], lw=1.0)
ax.text(-0.04, before[i], f"{before[i]:.2f}", ha="right", va="center",
fontsize=FS - 2, color=COLORS[i % 4])
ax.text(1.04, after[i], f"{after[i]:.2f}", ha="left", va="center",
fontsize=FS - 2, color=COLORS[i])
ax.set_xticks([0, 1])
ax.set_xticklabels(["调整前", "调整后"])
ax.set_xlim(-0.35, 1.35)
ax.set_ylim(0.15, 1.16)
ax.set_xlabel("电价方案")
ax.set_ylabel("电价 / (元/(kW·h))")
legend(ax, "lower left", ncol=2, fontsize=FS - 2)
save(fig, "43_坡形图", "43_坡形图_峰谷电价调整")
def sl_04():
"""各节点电压治理前后的坡形图。"""
fig, ax = new_fig(left=0.20)
node = ["N1", "N2", "N3", "N4", "N5"]
before = np.array([9.72, 9.68, 9.61, 9.58, 9.65])
after = np.array([10.02, 9.98, 9.94, 9.91, 9.96])
x = [0, 1]
for i in range(len(node)):
ax.plot(x, [before[i], after[i]], marker=MARKERS[i % 4], ms=4,
color=COLORS[i % 4], lw=1.0)
ax.text(-0.04, before[i], f"{before[i]:.2f}", ha="right", va="center",
fontsize=FS - 2, color=COLORS[i % 4])
ax.set_xticks([0, 1])
ax.set_xticklabels(["治理前", "治理后"])
ax.set_xlim(-0.35, 1.30)
ax.set_ylim(9.50, 10.12)
ax.set_xlabel("治理阶段")
ax.set_ylabel("节点电压 " + IT["U"] + " / kV")
legend(ax, "lower right", ncol=2, fontsize=FS - 2)
save(fig, "43_坡形图", "43_坡形图_电压治理前后")
def sl_05():
"""年度关键指标的坡形图。"""
fig, ax = new_fig(left=0.20)
year = ["2023", "2024", "2025"]
items = ["线损率", "供电可靠率", "新能源占比"]
data = np.array([[4.92, 4.62, 4.18],
[99.86, 99.92, 99.96],
[12.4, 18.6, 26.2]])
for i, nm in enumerate(items):
v = data[i] / data[i].max()
ax.plot([0, 1, 2], v, marker=MARKERS[i], ms=4, color=COLORS[i],
lw=1.0, label=nm)
ax.set_xticks([0, 1, 2])
ax.set_xticklabels(year)
ax.set_xlim(-0.3, 2.3)
ax.set_ylim(0.4, 1.06)
ax.set_xlabel("年份")
ax.set_ylabel("归一化指标值")
legend(ax, "lower right", ncol=1, fontsize=FS - 2)
save(fig, "43_坡形图", "43_坡形图_年度指标变化")
说明
- 图片尺寸 1181×944 px(100 mm × 80 mm @ 300 dpi),三维图为 1181×1122 px。
- 图内不放标题,图题由本文件的二级/三级标题承担。
- 数据为贴近广东实际量级的仿真算例,随机种子固定,重跑结果一致。
浙公网安备 33010602011771号