figure('Units', 'pixels', 'Position', [100 100 800 675]);
Sobol_N5 = xlsread('RandomSequences.xlsx', 'N=5', 'B3:B102');
Halton_N5 = xlsread('RandomSequences.xlsx', 'N=5', 'C3:C102');
Rand_N5 = xlsread('RandomSequences.xlsx', 'N=5', 'D3:D102');
LHC_N5 = xlsread('RandomSequences.xlsx', 'N=5', 'E3:E102');
Sobol_N50 = xlsread('RandomSequences.xlsx', 'N=50', 'B3:B102');
Halton_N50 = xlsread('RandomSequences.xlsx', 'N=50', 'C3:C102');
Rand_N50 = xlsread('RandomSequences.xlsx', 'N=50', 'D3:D102');
LHC_N50 = xlsread('RandomSequences.xlsx', 'N=50', 'E3:E102');
Sobol_N500 = xlsread('RandomSequences.xlsx', 'N=500', 'B3:B102');
Halton_N500 = xlsread('RandomSequences.xlsx', 'N=500', 'C3:C102');
Rand_N500 = xlsread('RandomSequences.xlsx', 'N=500', 'D3:D102');
LHC_N500 = xlsread('RandomSequences.xlsx', 'N=500', 'E3:E102');
Sobol_N5000 = xlsread('RandomSequences.xlsx', 'N=5000', 'B3:B102');
Halton_N5000 = xlsread('RandomSequences.xlsx', 'N=5000', 'C3:C102');
Rand_N5000 = xlsread('RandomSequences.xlsx', 'N=5000', 'D3:D102');
LHC_N5000 = xlsread('RandomSequences.xlsx', 'N=5000', 'E3:E102');
Sobol = [Sobol_N5 Sobol_N50 Sobol_N500 Sobol_N5000];
Halton = [Halton_N5 Halton_N50 Halton_N500 Halton_N5000];
Rand = [Rand_N5 Rand_N50 Rand_N500 Rand_N5000];
LHC = [LHC_N5 LHC_N50 LHC_N500 LHC_N5000];
ci_Sobol = bootci(1000, @mean, Sobol);
ci_Halton = bootci(1000, @mean, Halton);
ci_Rand = bootci(1000, @mean, Rand);
ci_LHC = bootci(1000, @mean, LHC);
Media_tot_Sobol = mean(Sobol,1)';
Media_tot_Halton = mean(Halton,1)';
Media_tot_Rand = mean(Rand,1)';
Media_tot_LHC = mean(LHC,1)';
ci_Sobol = abs(ci_Sobol' - repmat(Media_tot_Sobol,1,2));
ci_Halton = abs(ci_Halton' - repmat(Media_tot_Halton,1,2));
ci_Rand = abs(ci_Rand' - repmat(Media_tot_Rand,1,2));
ci_LHC = abs(ci_LHC' - repmat(Media_tot_LHC,1,2));
ydata_m_Sobol = (Media_tot_Sobol');
ydata_m_Halton = (Media_tot_Halton');
ydata_m_Rand = (Media_tot_Rand');
ydata_m_LHC = (Media_tot_LHC');
xdata_m_Sobol = [5 50 500 5000];
[xData_Sobol, yData_Sobol] = prepareCurveData( xdata_m, ydata_m_Sobol );
[xData_Halton, yData_Halton] = prepareCurveData( xdata_m, ydata_m_Halton );
[xData_Rand, yData_Rand] = prepareCurveData( xdata_m, ydata_m_Rand );
[xData_LHC, yData_LHC] = prepareCurveData( xdata_m, ydata_m_LHC );
hFit_Sobol = plot(xData_Sobol, yData_Sobol,'.');
hold on
hFit_Halton = plot(xData_Halton, yData_Halton,'.');
hFit_Rand = plot(xData_Rand, yData_Rand,'.');
hFit_LHC = plot(xData_LHC, yData_LHC,'.');
hE_Sobol = errorbar(xdata_m, ydata_m_Sobol, ci_Sobol(:,1), ci_Sobol(:,2));
hE_Halton = errorbar(xdata_m, ydata_m_Halton, ci_Halton(:,1), ci_Halton(:,2));
hE_Rand = errorbar(xdata_m, ydata_m_Rand, ci_Rand(:,1), ci_Rand(:,2));
hE_LHC = errorbar(xdata_m, ydata_m_LHC, ci_LHC(:,1), ci_LHC(:,2));
hXLabel = xlabel('Configuration to be evaluate');
hYLabel = ylabel('Objective Function');
%xlim([1 9]);
%ylim([8.074 8.106]);
set(hFit_Sobol , ...
'Color' , [0 .2 .6] );
set(hE_Sobol , ...
'LineStyle' , 'none' , ...
'Marker' , '.' , ...
'Color' , [0 .2 .6], ...
'markersize', 6);
set(hE_Halton , ...
'LineStyle' , 'none' , ...
'Marker' , '.' , ...
'Color' , [.8 .3 .3], ...
'markersize', 6);
set(hE_Rand , ...
'LineStyle' , 'none' , ...
'Marker' , '.' , ...
'Color' , [.2 .6 .1], ...
'markersize', 6);
set(hE_LHC , ...
'LineStyle' , 'none' , ...
'Marker' , '.' , ...
'Color' , [.4 .2 .7], ...
'markersize', 6);
hLegend = legend([hE_Sobol hE_Halton hE_Rand hE_LHC],'Sobol','Halton','Rand','LHC', 'location', 'NorthEast' );
set(gca,'XTick',[5 50 500 5000]);
% set(gca,'xscale','log')
THIS是我使用的.xls 我需要将每个错误栏并排放置在相同的N.例如,我希望在Sobol,Halton,Rand和LHC之间稍微转换为N = 5然后大转移并再次在Sobol,Halton,Rand和LHC之间转换为N = 0 ....我需要获得这样的东西:
答案 0 :(得分:2)
这是您实现所需目标的一种方式。它结合了轴向位移和对数x轴。
% create dummy data (I do not have your data)
xdata = [5 50 500 5000];
ydata = rand(1,4);
yerr = rand(4,4)./10;
% the first plot just introduces the logx feature
fig = figure;
hold on
errorbar(xdata,ydata(1,:),yerr(1,:),yerr(2,:),'ob');
errorbar(xdata,ydata(1,:),yerr(3,:),yerr(4,:),'or');
ax = get(fig,'CurrentAxes');
set(ax,'XScale','log')
set(ax,'XTick',[5 50 500 5000])
hold off
但是,因为我选择了相同的y数据,所以这些点重叠(就像在数据中一样)。因此,我介绍了向x坐标的转换:
N = 2 % number of datasets
% spread x coordinates
INTERVAL = 0.1;
FACTORS = linspace(-1*INTERVAL,INTERVAL,N);
xdataNew = zeros(N,size(xdata,2));
for ii=1:N
for jj=1:size(xdata,2)
xdataNew(ii,jj) = xdata(1,jj) + FACTORS(ii)*xdata(1,jj);
end
end
fig2 = figure;
hold on
errorbar(xdataNew(1,:),ydata(1,:),yerr(1,:),yerr(2,:),'ob');
errorbar(xdataNew(2,:),ydata(1,:),yerr(3,:),yerr(4,:),'or');
ax2 = get(fig2,'CurrentAxes');
set(ax2,'XScale','log')
set(ax2,'XTick',[5 50 500 5000])
hold off
使用此图,您现在可以获得相同位移的数据点。但是,你必须弄清楚x轴标记,以表明两个点属于同一个x值。