首页 > 其他分享 >MATLAB Gallary

MATLAB Gallary

时间:2023-03-17 11:34:46浏览次数:44  
标签:f1 FontName ft cm FontSize MATLAB Gallary barospf

组内用的比较专业的出图MATLAB代码:

rng(10);
N = 10000;
X1 = exprnd(1, 1, N);
X2 = exprnd(1, 1, N);

ft = 'times new roman';
f1 = figure(1);
x = 0:0.1:2;

[N1,edges1] = histcounts(X1, x);
[N2,edges2] = histcounts(X2, x);
h1 = N1 ./ length(X1);
h2 = N2 ./ length(X2);

w = 0.05;
w2 = 0.03;

x = x + (x(2) - x(1)) / 2;
x = x(1:end - 1);

bar(x - w/2, h1, 0.32);
hold on
bar(x + w2/2, h2, 0.32);
grid on
xlim([0,2])

xlabel('X Label', 'FontSize',12, 'FontName', ft)
ylabel('Y Label', 'FontSize',12,'FontName', ft)

legend({'X1', 'X2'}, 'FontSize',14,...
     'FontName', ft);

saveas(f1,'results.png')
saveas(f1,'results','epsc')

addpath('plottools')  % 需要这部分向我要一下。
f1 = figure(1);
rng(10)
ft = 'times new roman';
cm = colororder; % or replace with the desired colormap

x = 6:8;

y1 = rand(3, 2);
y2 = rand(3, 2);

barflow = bar(x - 0.22, y1, 0.4, 'stacked');
barflow(1).FaceColor = cm(1,:);
hatchfill2(barflow(1),'single','HatchAngle',45,'hatchcolor','black');
barflow(2).FaceColor = cm(1,:);

hold on
barospf = bar(x + 0.22, y2, 0.4, 'stacked');
barospf(1).FaceColor = cm(2,:);
barospf(2).FaceColor = cm(2,:);
hatchfill2(barospf(1),'single','HatchAngle',45,'hatchcolor','black');

xlim([5.5 8.5])
grid minor

xticks(6:8)
xticklabels({'6','7','8'})

bars = [barflow, barospf];
legendData = {'Access Delay w/ MaMED','SDN Delay w/ MaMED',...
    'Access Delay w/ SPF', 'SDN Delay w/ SPF'};

[legend_h, object_h, plot_h, text_str] = ...
    legendflex(bars, legendData, 'Padding', ...
    [2, 2, 10], 'FontSize', 12);

hatchfill2(object_h(6), 'single', 'HatchAngle', 45, 'HatchDensity', 80/4, 'HatchColor', 'black');
hatchfill2(object_h(8), 'single', 'HatchAngle', 45, 'HatchDensity', 80/4, 'HatchColor', 'black');

grid on
xlabel('Number of Channels Used By the IoT Gateway','FontSize', 12, 'FontName', ft)
ylabel('Average Delay (ms)','FontName', ft, 'FontSize', 12)

saveas(f1,'delay_comparison.png')
saveas(f1,'delay_comparison','epsc')

标签:f1,FontName,ft,cm,FontSize,MATLAB,Gallary,barospf
From: https://www.cnblogs.com/uceec00/p/17226062.html

相关文章