2 Line Styles for A Single Plot- How to Change Plotting Styles

14 次查看(过去 30 天)
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

采纳的回答

Alan Stevens
Alan Stevens 2021-2-18
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 个评论
Maria Raheb
Maria Raheb 2021-2-19
Thank you! Also, what do you mean by "pointed to by," and is "max" used?
Alan Stevens
Alan Stevens 2021-2-19
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by