您可以自定义从 MATLAB 函数 'ecdf' 生成的绘图吗?

Can you customize the plot generated from the MATLAB function 'ecdf'?

我发现当我使用 'plot' 函数时我可以很容易地自定义,但我似乎不能用 'ecdf' 函数做同样的事情。您可以自定义 ecdf 的显示方式吗?主要是,我希望线宽更粗,以便人们可以轻松地追踪它(很难在我的图的右侧看到它与图的边界重合)。谢谢!

ecdf(asset1)
title("Empirical Distribution Function of Asset Fluctuations")
xlabel("Value of Fluctuations")
ylabel("P(X<=x)")
  • 首先,使用h = get(gca,'children')
  • 获取当前图
  • 然后使用set helper自定义绘图,比如set(h,'LineWidth',3)

插图

rng('default')

% Given data
R = wblrnd(100,2,100,1);

ecdf(R,'Function','survivor','Alpha',0.05,'Bounds','on');

% Get plotted lines, 3 in total
h = get(gca,'children');


% Customize First line 
set(h(1),'LineWidth',3, 'color', 'red', 'LineStyle', '-');

% Customize second line 
set(h(2),'LineWidth',15, 'color', 'blue', 'LineStyle', '-');

% Customize third line 
set(h(3),'LineWidth',8, 'color', 'green', 'Marker', '+', 'LineStyle', '-');

% axes label
xlabel('Xlabel', 'color', 'red')
ylabel('Ylabel', 'color', 'red')
xticklabels({'X1'; 'X2'; 'X3';'X4'; 'X5'})
yticklabels({'Y1'; 'Y2'; 'Y3';'Y4'; 'Y5'; 'Y6'; 'Y7'; 'Y8';'Y9'; 'Y10'})
% display ylabel horizontally
hYLabel = get(gca,'YLabel');
set(hYLabel,'rotation',0,'VerticalAlignment','middle',  'HorizontalAlignment','right')


% Customizing axes /Borders/ labels 
set(gca,'XGrid','on', 'YGrid', 'on', 'Fontsize', 20,'linewidth', 5);


% legend
[~,b] = legend([h(1) h(2) h(3)],{'Line 1 ','Line 2', 'Line 3'}, 'FontSize',30);
set(findobj(b,'-property','MarkerSize'),'MarkerSize',30);

title('Customized ecdf','color', 'red', 'fontSize', 30)



Default ecdf


Customized ecdf