Message Boards Message Boards

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

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:
POSTED BY: Tomáš Hruš
3 Replies
Posted 9 years ago

Patrik & Marco - thank you very much!

POSTED BY: Tomáš Hruš

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 BY: Patrik Ekenberg

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]}]

enter image description here

Cheers,

Marco

POSTED BY: Marco Thiel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract