热图(`heatmap`)

热图(heatmap)

03_统计与矩阵 5 张 MATLAB R2023b 100 mm 宽 @ 300 dpi

这个方法适合什么

矩阵数据的色阶表达,自带行列标签与色条。适合:月×时负荷矩阵、节点×时刻电压偏差、多指标多方案的评估矩阵。

电气场景

1 月时平均负荷热图

2 各节点电压偏差热图

3 谐波电流含有率热图

4 设备缺陷类型统计热图

5 各分区功率因数热图

代码

脚本 p3_stats_matrix.m 中对应 heatmap 的一段,SEL 用于选择只跑某几个方法。

if any(SEL==4)
    rng(404);
    HP = [0.185 0.150 0.625 0.760];     % 100 mm 宽下的防裁切位置

    % ---- 4.1 月时平均负荷热图 ----
    hr = 1:2:23;
    mn = ml_tx(arrayfun(@(k) sprintf('%d 月',k),1:12,'UniformOutput',false));
    base = 0.62 + 0.30*exp(-((hr-10).^2)/18) + 0.34*exp(-((hr-19).^2)/10);
    Cm = zeros(12,12);
    for m = 1:12
        s = 0.88 + 0.10*sin((m-4)/12*2*pi);
        if m >= 6 && m <= 8, s = s + 0.10; end
        Cm(m,:) = base*s + 0.02*randn(1,12);
    end
    f = ml_fig(PP,100,85);
    h = heatmap(f,string(hr-1),mn,Cm);
    h.FontName = '宋体'; h.FontSize = 10;
    h.XLabel = ml_tx('时刻 / h(色阶:<i>P</i> / MW)'); h.YLabel = ml_tx('月份');
    h.Colormap = parula; h.CellLabelColor = 'none';
    h.Position = HP;
    save_png(f,FIGD,'月时平均负荷热图');

    % ---- 4.2 各节点电压偏差热图 ----
    nd = ml_tx({'N1','N2','N3','N4','N5','N6','N7','N8'});
    Cm = 0.9*randn(8,12) + 0.6;
    Cm(3,:) = Cm(3,:) - 1.6;  Cm(7,:) = Cm(7,:) + 1.2;
    f = ml_fig(PP,100,85);
    h = heatmap(f,string(hr-1),nd,Cm);
    h.FontName = '宋体'; h.FontSize = 10;
    h.XLabel = ml_tx('时刻 / h(色阶:Δ<i>U</i> / %)'); h.YLabel = ml_tx('节点编号');
    h.Colormap = parula; h.CellLabelColor = 'none';
    h.Position = HP;
    save_png(f,FIGD,'各节点电压偏差热图');

    % ---- 4.3 谐波电流含有率热图 ----
    horder = string(3:2:25);
    site   = ml_tx({'母线 I','母线 II','馈线 1','馈线 2','馈线 3'});
    Cm = [12.4 8.6 5.2 3.1 2.0 1.4 0.9 0.6 0.4 0.3 0.2 0.1
           9.8 6.4 4.1 2.6 1.7 1.1 0.8 0.5 0.3 0.2 0.1 0.1
          15.2 9.1 5.8 3.4 2.2 1.5 1.0 0.7 0.4 0.3 0.2 0.1
           7.6 5.2 3.4 2.1 1.4 0.9 0.6 0.4 0.3 0.2 0.1 0.1
           4.2 3.1 2.2 1.5 1.0 0.7 0.5 0.3 0.2 0.1 0.1 0.0];
    f = ml_fig(PP,100,85);
    h = heatmap(f,horder,site,Cm);
    h.FontName = '宋体'; h.FontSize = 10;
    h.XLabel = ml_tx('谐波次数(<i>I</i>_{h} / %)'); h.YLabel = ml_tx('测点');
    h.Colormap = parula; h.CellLabelColor = 'none';
    h.Position = [0.185 0.180 0.625 0.720];
    save_png(f,FIGD,'谐波电流含有率热图');

    % ---- 4.4 设备缺陷类型统计热图 ----
    dev = ml_tx({'变压器','断路器','隔离开关','避雷器','电缆','互感器'});
    dfc = ml_tx({'发热','放电','渗漏','机械','绝缘'});
    Cm = [38 21 16  9 27
          14 11  3 22  6
           6  4  2 18  3
           5 19  1  2 11
          12 15  4  6 24
           7  9  8  5 13];
    f = ml_fig(PP,100,85);
    h = heatmap(f,dfc,dev,Cm);
    h.FontName = '宋体'; h.FontSize = 10;
    h.XLabel = ml_tx('缺陷类型(色阶:次数 / 次)'); h.YLabel = ml_tx('设备类型');
    h.Colormap = flipud(hot); h.CellLabelFormat = '%d';
    h.Position = [0.235 0.155 0.575 0.755];
    save_png(f,FIGD,'设备缺陷类型统计热图');

    % ---- 4.5 各分区功率因数热图 ----
    zone = ml_tx({'中心区','工业区','新区','郊区'});
    Cm = [0.94 0.93 0.92 0.90 0.91 0.93 0.94 0.94 0.93 0.92 0.93 0.95
          0.88 0.87 0.86 0.85 0.86 0.88 0.89 0.89 0.88 0.87 0.88 0.90
          0.91 0.90 0.89 0.88 0.89 0.91 0.92 0.92 0.91 0.90 0.91 0.93
          0.83 0.82 0.81 0.80 0.81 0.83 0.84 0.84 0.83 0.82 0.83 0.85];
    f = ml_fig(PP,100,85);
    h = heatmap(f,string(1:12),zone,Cm);
    h.FontName = '宋体'; h.FontSize = 10;
    h.XLabel = ml_tx('月份(色阶:cos<i>\phi</i>)'); h.YLabel = ml_tx('供电分区');
    h.Colormap = parula; h.CellLabelColor = 'none';
    h.Position = HP;
    save_png(f,FIGD,'各分区功率因数热图');
end
posted @ 2026-11-09 00:05  小青蛙电气  阅读(2)  评论(0)    收藏  举报