2 Line Styles for A Single Plot- How to Change Plotting Styles
14 views (last 30 days)
Show older comments
Maria Raheb
on 18 Feb 2021
Commented: Alan Stevens
on 19 Feb 2021
I've attached a picture of a plot and circled where I would like to change the solid line I circled to a different style (like a dashed line). How do I do that?
B = 0.75; C = 0.8; p =0.5;
A = linspace((1-p)*B*(1-C),1.5);
figure (2)
[l1,~]= bifurcation_lysogen_pops(A);
[~,l2]= bifurcation_lysogen_pops(A);
plot(A,l1, A, l2)
yline(0); %E_H and E_0 l
ylim([-0.2 1])
xlim([0 1])
function [l1,l2] = bifurcation_lysogen_pops(A)
B = 0.75; C = 0.8; p =0.5;
v= B*(1-C);
l1 = (C*p*v)./(A-(1-p)*v); %E* lysogen population
l2 = (B-A)./B; %E_VL lysogen population
end
l2 is the red plot and l1 is the blue plot
0 Comments
Accepted Answer
Alan Stevens
on 18 Feb 2021
Here's one possibility
B = 0.75; C = 0.8; p =0.5;
A = linspace((1-p)*B*(1-C),1.5);
figure (2)
[l1,l2]= bifurcation_lysogen_pops(A);
l1(1)=[]; l2(1)=[]; A(1)= []; % get rid of infinity in l1;
hiindx = find(l1>l2 & A<0.5);
Ahi = A(hiindx);
l1hi = l1(hiindx);
Alo = A(max(hiindx):end);
l1lo = l1(max(hiindx):end);
plot(Ahi,l1hi,'b--',Alo,l1lo,'b',A,l2)
yline(0); %E_H and E_0 l
ylim([-0.2 2])
xlim([0 1])
function [l1,l2] = bifurcation_lysogen_pops(A)
B = 0.75; C = 0.8; p =0.5;
v= B*(1-C);
l1 = (C*p*v)./(A-(1-p)*v); %E* lysogen population
l2 = (B-A)./B; %E_VL lysogen population
end
5 Comments
Alan Stevens
on 19 Feb 2021
The vector l1, say, has values listed in order: l1(1), l1(2), l1(3), ...etc. The "find" command finds the numbers 1, 2, 3, etc that correspond to the specified conditions. So, for example, if the values l1(1) and l1(2) were larger than l2(1) and l2(2) and all the other values of l1 were smaller than the other values of l2, then hiindx would be a vector consisting of the numbers 1 and 2 (i.e. hiindx would be [1, 2]). That is hiindx would "point to" the first two vaues of a vector. l1(hiindx) would "point to" l1(1) and l1(2). A(hiindx) would "point to" A(1) and A(2).
Since the values of hiindx increase in value. the last one will be the largest, so max(hiindx) will pick out the last value. One could also use hiindx(end), for example, to do the same thing.
Hope this helps.
More Answers (0)
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!