looping figures with text labels

Hello,
I am trying to repeat a set of text labels to figures that are being generated in a for loop
%M1 is a 49 x k1 matrix that contains the 49 y values that will be looped k1 times
%X1 is a 49 x 1 matrix that contains the 49 x values
% stcM1C is a 49 x 1 vector that contains the 49 strings that need to be printed in each figure
%%figure loop with labels
stcM1C=char(stc(:,1));
for k1=1:1:k1;
i1=M1(:,k1);
x1=X1(:,1);
figure(k1)
plot(x1,i1,'ok','MarkerFaceColor','g')
hold on
text(x1,i1,stcM1C,...
'fontsize',6,...
'verticalalignment','bottom');
end
Any assistance would be great.
thanks, Mark

 Accepted Answer

Image Analyst
Image Analyst on 14 May 2013
Edited: Image Analyst on 14 May 2013
I don't know what stc1 is, but I think it should be inside the loop if you want it to change with every figure.
% Create a string inside the loop that depends on k1.
caption = sprintf('This is figure #%d', k1); % Or use, stc1.
% Add title above the axes.
title(caption, 'FontSize', 15);

5 Comments

Thanks Image Analyst,
I fixed some things in my original post. Please review.
Sorry for not being exact. The stc1 is a 49 x 1 vector of strings that are annotations for the 49 rows of both matrices (i.e. i1=M1(1:49,k1) and x1=X1(1:49,1)). As such, the labels should not change as the xy data pairs change between the k1 figures.
Basically I would like to label the 49 xy data pairs in each figure with the same labels in stc1, but I cannot get the text function to work properly.
Thanks for your assistance,
Mark
You're still not indexing stcM1C. Try this:
text(x1,i1,stcM1C(k1,:),...
Thanks for the prompt response Image Analyst.
The thing is that I am trying to print ALL 49 labels that are in stcM1C over and over again k1 times in each figure. So to give you a visual I am trying to generate k1 scatter plots with linear regression. I have been able to loop the figures with the regressions (I left out the extra code for simplicity)and everything else with the exception of the xy value pair labels that are in vector stcM1C.
My problem is that I cant seem to get the text function to loop the xy value pair labels over and over again k1 times.
I appreciate your assistance,
Mark
Give me code to generate stcM1C.
Mark Cejas
Mark Cejas on 14 May 2013
Edited: Mark Cejas on 15 May 2013
Hi Image Analyst,
I managed to figure it out.
%M1 is a 49 x k1 matrix that contains the 49 y values that will be looped k1 times %X1 is a 49 x 1 matrix that contains the 49 x values % stcM1C is a 49 x 1 vector that contains the 49 strings that need to be printed in each figure
%% figure loop with labels
stcM1C=char(stc(:,1));
for k1=1:1:k1;
x1=X1(:,1);
figure(k1)
plot(x1,i1,'ok','MarkerFaceColor','g')
hold on
for g1=1:49;
text(x1(g1,k1),i1(g1,k1),stcM1C(g1,:),...
'fontsize',6,...
'verticalalignment','bottom');
end
end
thanks!!!!

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!