蜂群图(`swarmchart`)

蜂群图(swarmchart)

02_柱与散点 5 张 MATLAB R2023b 100 mm 宽 @ 300 dpi

这个方法适合什么

点自动错开不重叠,小样本时既看单个值又看密度。适合:各馈线电流实测值、各方案效率试验点、各测点温升实测。

电气场景

1 各主变负载率蜂群图

2 各类用户电压偏差蜂群图

3 三种导线载流量蜂群图

4 各节点谐波畸变蜂群图

5 四季日负荷率蜂群图

代码

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

if any(SEL==7)
    rng(31);
    % ---- 7.1 各主变负载率 ----
    nm = {'1 号','2 号','3 号','4 号','5 号'};
    mu = [72.4 61.8 84.6 55.2 78.9];
    Y  = []; X = [];
    for k = 1:5
        v = mu(k) + 7.5*randn(14,1);
        Y = [Y; v]; X = [X; k*ones(14,1)];                 %#ok<AGROW>
    end
    f  = ml_fig(PP,100,80);
    ax = axes('Parent',f,'Position',[0.175 0.190 0.770 0.755]);
    h  = swarmchart(ax,X,Y,16,C(1,:),'filled');
    set(h,'MarkerFaceAlpha',0.70,'MarkerEdgeColor','none');
    set(ax,'XTick',1:5,'XTickLabel',ml_tx(nm),'XTickLabelRotation',0);
    xlabel(ml_tx('变电站主变编号'));
    ylabel(ml_tx('日最大负载率 <i>\beta</i> / %'));
    xlim(ax,[0.4 5.6]); ylim(ax,[40 112]);
    lg = legend(ax,h,ml_tx('30 天实测样本'),'Location','northeast', ...
                'Orientation','horizontal');
    ml_style_legend(lg,PP);
    save_png(f,FIGD,'各主变负载率蜂群图');

    % ---- 7.2 各类用户电压偏差 ----
    nm = {'居民','商业','工业','农业'};
    mu = [-3.6 -1.9 -0.8 -4.8];
    sg = [1.35 0.95 1.10 1.05];
    Y  = []; X = [];
    for k = 1:4
        v = mu(k) + sg(k)*randn(16,1);
        Y = [Y; v]; X = [X; k*ones(16,1)];                 %#ok<AGROW>
    end
    f  = ml_fig(PP,100,80);
    ax = axes('Parent',f,'Position',[0.175 0.190 0.770 0.755]);
    h  = swarmchart(ax,X,Y,16,C(2,:),'filled');
    set(h,'MarkerFaceAlpha',0.70,'MarkerEdgeColor','none');
    set(ax,'XTick',1:4,'XTickLabel',ml_tx(nm),'XTickLabelRotation',0);
    xlabel(ml_tx('用户类别'));
    ylabel(ml_tx('电压偏差 <i>\delta U</i> / %'));
    xlim(ax,[0.4 4.6]); ylim(ax,[-9.8 3.0]);
    lg = legend(ax,h,ml_tx('台区出口实测'),'Location','northeast', ...
                'Orientation','horizontal');
    ml_style_legend(lg,PP);
    save_png(f,FIGD,'各类用户电压偏差蜂群图');

    % ---- 7.3 三种导线载流量 ----
    nm = {'LGJ-95','LGJ-150','LGJ-240'};
    mu = [335 445 610];
    sg = [26 32 38];
    Y  = []; X = [];
    for k = 1:3
        v = mu(k) + sg(k)*randn(18,1);
        Y = [Y; v]; X = [X; k*ones(18,1)];                 %#ok<AGROW>
    end
    f  = ml_fig(PP,100,80);
    ax = axes('Parent',f,'Position',[0.175 0.190 0.770 0.755]);
    h  = swarmchart(ax,X,Y,16,C(3,:),'filled');
    set(h,'MarkerFaceAlpha',0.70,'MarkerEdgeColor','none');
    set(ax,'XTick',1:3,'XTickLabel',ml_tx(nm),'XTickLabelRotation',0);
    xlabel(ml_tx('导线型号'));
    ylabel(ml_tx('允许载流量 <i>I</i> / A'));
    xlim(ax,[0.4 3.6]); ylim(ax,[240 720]);
    lg = legend(ax,h,ml_tx('18 组温升试验'),'Location','northeast', ...
                'Orientation','horizontal');
    ml_style_legend(lg,PP);
    save_png(f,FIGD,'三种导线载流量蜂群图');

    % ---- 7.4 各节点谐波畸变率 ----
    nm = {'节点 1','节点 2','节点 3','节点 4','节点 5','节点 6'};
    mu = [3.8 4.6 5.9 3.2 6.8 4.1];
    sg = [0.42 0.51 0.63 0.38 0.72 0.45];
    Y  = []; X = [];
    for k = 1:6
        v = mu(k) + sg(k)*randn(12,1);
        Y = [Y; v]; X = [X; k*ones(12,1)];                 %#ok<AGROW>
    end
    f  = ml_fig(PP,100,80);
    ax = axes('Parent',f,'Position',[0.175 0.190 0.770 0.755]);
    h  = swarmchart(ax,X,Y,14,C(4,:),'filled');
    set(h,'MarkerFaceAlpha',0.70,'MarkerEdgeColor','none');
    set(ax,'XTick',1:6,'XTickLabel',ml_tx(nm),'XTickLabelRotation',0);
    xlabel(ml_tx('母线节点'));
    ylabel(ml_tx('电压总谐波畸变率 <i>U</i>_{THD} / %'));
    xlim(ax,[0.4 6.6]); ylim(ax,[1.5 9.6]);
    lg = legend(ax,h,ml_tx('12 次连续监测'),'Location','northeast', ...
                'Orientation','horizontal');
    ml_style_legend(lg,PP);
    save_png(f,FIGD,'各节点谐波畸变蜂群图');

    % ---- 7.5 四季日负荷率 ----
    nm = {'春季','夏季','秋季','冬季'};
    mu = [0.78 0.86 0.76 0.82];
    sg = [0.045 0.038 0.050 0.042];
    Y  = []; X = [];
    for k = 1:4
        v = mu(k) + sg(k)*randn(20,1);
        Y = [Y; v]; X = [X; k*ones(20,1)];                 %#ok<AGROW>
    end
    f  = ml_fig(PP,100,80);
    ax = axes('Parent',f,'Position',[0.175 0.190 0.770 0.755]);
    h  = swarmchart(ax,X,Y,14,C(5,:),'filled');
    set(h,'MarkerFaceAlpha',0.70,'MarkerEdgeColor','none');
    set(ax,'XTick',1:4,'XTickLabel',ml_tx(nm),'XTickLabelRotation',0);
    xlabel(ml_tx('季节'));
    ylabel(ml_tx('日负荷率 <i>\lambda</i>'));
    xlim(ax,[0.4 4.6]); ylim(ax,[0.62 1.00]);
    lg = legend(ax,h,ml_tx('20 个典型日'),'Location','northeast', ...
                'Orientation','horizontal');
    ml_style_legend(lg,PP);
    save_png(f,FIGD,'四季日负荷率蜂群图');
end
posted @ 2026-11-09 00:04  小青蛙电气  阅读(4)  评论(0)    收藏  举报