0
|
5548 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
GROUPS:

# Formating of a graph

Posted 9 years ago
 I have this part of code (see below) - and I cannot understand, why the first line in the graph is not red and why the second line is dashed... See attachement... (Mathematica 10.3.0.0, Windows 10 - 64 bit) Thank you for help! In[22]:= f2 ff2 Out[22]= (x/(k4 + x))^k5 Out[23]= k5 (x/(k4 + x))^(-1 + k5) (-(x/(k4 + x)^2) + 1/(k4 + x)) In[24]:= Plot[{f2, ff2} /. {k4 -> 1, k5 -> 1}, {x, 0, 5}, AxesOrigin -> {0, 0}, GridLines -> Automatic, PlotRange -> {Automatic, Full}, PlotStyle -> {Directive[Red, Dashed], Directive[Blue, Thin]}]  Attachments:
3 Replies
Sort By:
Posted 9 years ago
 Patrik & Marco - thank you very much!
Posted 9 years ago
 Edit: Just noticed Marco beat me to it (: cheers!Hi Tomá!I think (I am not a 100% sure though) that it has to do with when the expressions are evaluated. I think that the when the Plot command applies the PlotStyle, the expression: {f2, ff2} /. {k4 -> 1, k5 -> 1} haven't been evaluated yet and as it is a single expression, rather than a list of two expressions, all PlotStyles are applied on top of each other, rather than individually on each expression. So you get a dashed and thin blue line.Forcing the expression to be evaluated will for example solve your problem: Plot[Evaluate[{f2, ff2} /. {k4 -> 1, k5 -> 1}], {x, 0, 5}, AxesOrigin -> {0, 0}, GridLines -> Automatic, PlotRange -> {Automatic, Full}, PlotStyle -> {Directive[Red, Dashed], Directive[Blue, Thin]}] As I said, I am not a hundred percent sure that this is what is happening but the above code should at least fix the problems you are having!Patrik
Posted 9 years ago
 Hi,it depends on where you substitute and whether that is a delayed definition or not. f2[x_] := (x/(k4 + x))^k5 ff2[x_] := k5 (x/(k4 + x))^(-1 + k5) (-(x/(k4 + x)^2) + 1/(k4 + x)) Plot[{f2[x] /. {k4 -> 1, k5 -> 1}, ff2[x] /. {k4 -> 1, k5 -> 1}}, {x, 0, 5}, AxesOrigin -> {0, 0}, GridLines -> Automatic, PlotRange -> {Automatic, Full}, PlotStyle -> {Directive[Red, Dashed], Directive[Blue, Thin]}] Cheers,Marco