Plotting multiple graphs which are generated in loops on a single figure

I have the following code:
antibodies = {'Rel-A','p-Rel-A','IkBa','p-IkBa','A20'};
x_axis = {'PBS','GOX','TNF','L','M','H'};
colours = {'r','g','b','m','c'};
Y_axis = 'OD';
hold on
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
figure('name','Time Course,GOX,Cyt')
for j=1:5,
subplot(5,1,j)
errorbar(avg_time_course_data{5}(j,1:3),avg_time_course_error{5}(j,1:3))
set(gca, 'XTick', 1:6, 'XTickLabel', x_axis)
title(antibodies(j))
ylabel = y_axis;
end
The output of this generates two figures, both a single column of graphs. These graphs are parallel in the sense that variables a, b, c, d and e are plotted against time at positions 'subplot(5,1,i); i=1:5' on both graphs. I want to condense this into a single graph without doing all the manual repetitive work of undoing the loops. (i.e. I want both a's on one axis etc.). I hope this is clear, does anybody know how to do this?
Thanks

4 件のコメント

Joakim Magnusson
Joakim Magnusson 2014 年 8 月 15 日
Do you want one figure with 5 subplots, and each subplot to plot two curves?
Ciaran
Ciaran 2014 年 8 月 15 日
Yes, exactly. would have been simpler if I could phrase it like that.
Joakim Magnusson
Joakim Magnusson 2014 年 8 月 15 日
編集済み: Joakim Magnusson 2014 年 8 月 15 日
What does "avg_time_course_data" and "avg_time_course_error" look like?
Ciaran
Ciaran 2014 年 8 月 15 日
They are both 1x18 cells with each cell having a 5x3 double matrix within them.

サインインしてコメントする。

 採用された回答

Joakim Magnusson
Joakim Magnusson 2014 年 8 月 15 日
I belive you should just do something like this:
antibodies = {'Rel-A','p-Rel-A','IkBa','p-IkBa','A20'};
x_axis = {'PBS','GOX','TNF','L','M','H'};
colours = {'r','g','b','m','c'};
Y_axis = 'OD';
hold on
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));
hold on;
errorbar(avg_time_course_data{5}(j,1:3),avg_time_course_error{5}(j,1:3));
set(gca, 'XTick', 1:6, 'XTickLabel', x_axis)
title(antibodies(j))
ylabel = y_axis;
end
does it work?

2 件のコメント

Ciaran
Ciaran 2014 年 8 月 15 日
Yes that's exactly what I wanted. So simple I feed stupid for asking. Thanks
Joakim Magnusson
Joakim Magnusson 2014 年 8 月 15 日
Don't, i didn't know it right away either. Accept my answer if you you got what you wanted! :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by