如何在Matlab中正确运行ylabel函数

时间:2014-08-14 11:20:31

标签: matlab plot label

所以我正在尝试使用此代码生成图表:

%initialize some variables
antibodies = {'Rel-A','p-Rel-A','IkBa','p-IkBa','A20'};
titles = {'PBS','GOX','TNF','L','M','H'};
x_axis = {'1h','3h','6h'};
y_axis = 'Optical Density';

%create figure
figure('name','Time Course,PBS,Cyt')
for j=1:5,
   subplot(5,1,j)
   errorbar(avg_time_course_data{2}(j,1:3),avg_time_course_error{2}(j,1:3))
   set(gca, 'XTick', 1:6, 'XTickLabel', x_axis)
   title(antibodies(j)) 
   ylabel(y_axis);   
end

当我运行这个脚本但是我得到的图但没有Y标签!有人知道为什么吗?

1 个答案:

答案 0 :(得分:1)

我在代码中更改了一些行。我还使用errorbar(rand(1,10), rand(10,1))进行了测试。

%initialize some variables
antibodies = {'Rel-A','p-Rel-A','IkBa','p-IkBa','A20'};
titles = {'PBS','GOX','TNF','L','M','H'};
x_axis = {'1h','3h','6h'};
y_axis = 'OD'; % I made the string shorter, because it was overlapping the other ylabel on my screen.

%create figure
figure('name','Time Course,PBS,Cyt')
for jj=1:5,
   subplot(5,1,jj)
   errorbar(rand(1,10), rand(10,1))
   set(gca, 'XTick', 1:6, 'XTickLabel', x_axis)
   title(antibodies(jj)) 
   set(get(gca,'YLabel'), 'String', y_axis); % The code now use a different method for setting the ylabel string.   
end

让我知道它是否对你有所帮助。