New Reply

Dynamic Legend in MatLab

 
Share Thread Thread Tools
Nov28-11, 05:42 PM   #1
 

Dynamic Legend in MatLab


Hello,

I am trying to do the following:

for i=1:3
semilogy(plot1,'r(-,:,d)',plot2,'b(-,:,d)',plot3,'k(-,:,d)');
legend('i legend1','i legend2',''i legend1'')
end

where I need to draw the same plots under different settings, such that each function has the same color under the different settings, but with different style, e.g: solid line in the first, dotted in the second, ... and so on. I also want to include the number i in the legend at each iteration. How to do that?

Thanks
PhysOrg.com
PhysOrg
science news on PhysOrg.com

>> Galaxies fed by funnels of fuel
>> The better to see you with: Scientists build record-setting metamaterial flat lens
>> Google eyes emerging markets networks
Dec2-11, 06:29 PM   #2
 
I'm not that sure that i understood what you wanted, however this thread came into my mind:
http://www.physicsforums.com/showpos...00&postcount=4
Dec2-11, 06:34 PM   #3
 
Blog Entries: 9
Recognitions:
Gold Membership Gold Member
This may be of use: http://www.mathworks.com/help/techdo...s/braliom.html
Dec2-11, 06:56 PM   #4
 
Blog Entries: 9
Recognitions:
Gold Membership Gold Member

Dynamic Legend in MatLab


Actually, if I'm understanding what you want to do, I think you could get away with using sprintf and format statements as inputs to the legend and semilogy functions.

Something like:
Code:
legend(sprintf('%i legend 1', i), sprintf('%i legend 2', i), sprintf('%i legend 1', i))
It's not pretty but it should work. You can do something similar for the line types with a cell array.
New Reply
Thread Tools


Similar Threads for: Dynamic Legend in MatLab
Thread Forum Replies
Matlab Legend Problem Math & Science Software 0
Matlab: dynamic data entry into structure Math & Science Software 6
Question about matlab figure legend. Math & Science Software 2
will you pass on the story to your son? General Discussion 6