平面bar图的一个问题
绘制了三个bar图,代码如下,设置一样,为什么第三个图会和其他两个不一样呢?求达人指教,谢谢clear
clc
close all
dno=;
endnum=;
data=rand(440,1)*100;
%data=1:440;
map=;
Hf_fig=figure('position',);
%作图1——上弦杆%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Ha_1=subplot(2,2,1);
set(Ha_1,'units','pixels');
set(Ha_1,'position',);
iA1_xuilabel=1;
A1_xuilabel=[];
while iA1_xuilabel<endnum(1)
A1_xuilabel=;
iA1_xuilabel=iA1_xuilabel+5;
end
clear iA1_xuilabel
if A1_xuilabel(end)<endnum(1)-2
A1_xuilabel=;
end
set(Ha_1,'xtick',A1_xuilabel);
data1=data(1:endnum(1));
x1=1:endnum(1);
Hb1_1=bar(x1,data1,'facecolor',,'EdgeColor',);
colormap(map);
set(Hb1_1,'barwidth',1.2)%调整柱状线的宽度
hold on
ddata1=zeros(size(data1,1),size(data1,2));
if ~isempty(dno(find(dno>=1&dno<=endnum(1))))
x1_dno=dno(find(dno>=1&dno<=endnum(1)));
ddata1=zeros(size(data1,1),size(data1,2));
for ix1_dno=1:length(x1_dno)
ddata1(x1_dno(ix1_dno))=data(x1_dno(ix1_dno));
end
clear ix1_dno
end
Hb1_2=bar(x1,ddata1,'facecolor',,'EdgeColor',);
set(Hb1_2,'barwidth',1.2)%调整柱状线的宽度
hold off
Hl1=legend('无损伤杆件','损伤杆件');
set(Ha_1,'box','off');
set(Ha_1,'TickLength',);
set(Ha_1,'ygrid','on');
set(get(Ha_1,'title'),'string','上弦杆损伤程度','fontweight','bold','fontsize',12,'units','pixels');
set(get(Ha_1,'title'),'position',);
set(get(Ha_1,'ylabel'),'string','差异百分比','units','pixels','position',[-25 125 0],'rotation',90);
set(get(Ha_1,'xlabel'),'string','杆件编号');
set(Ha_1,'xlim',);
%作图2——下弦杆%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Ha_2=subplot(2,2,2);
set(Ha_2,'units','pixels');
set(Ha_2,'position',);%算法有问题需要调整
iA2_xuitick=1+endnum(1);
A2_xuitick=[];
while iA2_xuitick<endnum(2)&&iA2_xuitick>endnum(1)
A2_xuitick=;
iA2_xuitick=iA2_xuitick+5;%每隔5个数生成一个x坐标标记
end
clear iA2_xuitick
if A2_xuitick(end)<endnum(2)-2
A2_xuitick=;
end
data2=data(1+endnum(1):endnum(2));
x2=1+endnum(1):endnum(2);
Hb2_1=bar(x2,data2,'facecolor',,'EdgeColor',);
colormap(map);
set(Hb2_1,'barwidth',1.2)%调整柱状线的宽度
hold on
ddata2=zeros(size(data2,1),size(data2,2));
if ~isempty(dno(find(dno>=1+endnum(1)&dno<=endnum(2))))
x2_dno=dno(find(dno>=1+endnum(1)&dno<=endnum(2)));
for ix2_dno=1:length(x2_dno)
ddata2(x2_dno(ix2_dno)-endnum(1))=data(x2_dno(ix2_dno));
end
end
Hb2_2=bar(x2,ddata2,'facecolor',,'EdgeColor',);
set(Hb2_2,'barwidth',1.2)%调整柱状线的宽度
hold off
Hl2=legend('无损伤杆件','损伤杆件');
set(Ha_2,'xtick',A2_xuitick);
set(Ha_2,'xticklabel',A2_xuitick);
set(Ha_2,'box','off');
set(Ha_2,'TickLength',);
set(Ha_2,'ygrid','on');
set(get(Ha_2,'title'),'string','下弦杆损伤程度','fontweight','bold','fontsize',12,'units','pixels');
set(get(Ha_2,'title'),'position',);
set(get(Ha_2,'ylabel'),'string','差异百分比','units','pixels','position',[-25 125 0],'rotation',90);
set(get(Ha_2,'xlabel'),'string','杆件编号');
set(Ha_2,'xlim',);
%作图3——腹杆%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Ha_3=subplot(2,2,);
set(Ha_3,'units','pixels');
set(Ha_3,'position',);%左60像素,高25像素,长度由数据量觉得,框高250
iA3_xuitick=1+endnum(2);
A3_xuitick=[];
while iA3_xuitick<endnum(3)&&iA3_xuitick>endnum(2)
A3_xuitick=;
iA3_xuitick=iA3_xuitick+5;%每隔5个数生成一个x坐标标记
end
clear iA3_xuitick
if A3_xuitick(end)<endnum(3)-2
A3_xuitick=;
end
data3=data(1+endnum(2):endnum(3));
x3=1+endnum(2):endnum(3);
Hb3_1=bar(x3,data3,'facecolor',,'EdgeColor',);
colormap(map);
set(Hb3_1,'barwidth',1.0)%调整柱状线的宽度
hold on
ddata3=zeros(size(data3,1),size(data3,2));
if ~isempty(dno(find(dno>=1+endnum(2)&dno<=endnum(3))))
x3_dno=dno(find(dno>=1+endnum(2)&dno<=endnum(3)));
for ix3_dno=1:length(x3_dno)
ddata3(x3_dno(ix3_dno)-endnum(2))=data(x3_dno(ix3_dno));
end
end
Hb3_2=bar(x3,ddata3,'facecolor',,'EdgeColor',);
set(Hb3_2,'barwidth',1.0)%调整柱状线的宽度
hold off
Hl3=legend('无损伤杆件','损伤杆件');
set(Ha_3,'xtick',A3_xuitick);
set(Ha_3,'xticklabel',A3_xuitick);
set(Ha_3,'box','off');
set(Ha_3,'TickLength',);
set(Ha_3,'ygrid','on');
set(get(Ha_3,'title'),'string','腹杆损伤程度','fontweight','bold','fontsize',12,'units','pixels');
set(get(Ha_3,'title'),'position',);
set(get(Ha_3,'ylabel'),'string','差异百分比','units','pixels','position',[-25 125 0],'rotation',90);
set(get(Ha_3,'xlabel'),'string','杆件编号');
set(Ha_3,'xlim',); 不清楚什么不一样? 附件的fig文件里面是图,后来发现是第三个图的edgecolor的设置没有成功(Hb3_1=bar(x3,data3,'facecolor',,'EdgeColor',);)。重新用set(Hb3_1,'EdgeColor',),就改过来了,谢谢Happy
页:
[1]