0
$\begingroup$

Let me give an example

 pfun = ParametricNDSolveValue[{y'[t] == a y[t], y[0] == 1}, y, {t, 0, 10}, {a}];

 Plot[Evaluate[Table[pfun[a][t], {a, -1, 1, .5}]], {t, 0, 1}, PlotRange -> All, PlotLegends -> Automatic]

which gives

enter image description here

How can I set, for example, that only the orange curve be thick. One would think to do

PlotStyle->{Default,Thick,Default,Default,Default}

But what if we do

Plot[Evaluate[Table[pfun[a][t], {a, -1, 1, .1}]], {t, 0, 1}, PlotRange -> All, PlotStyle -> Thick]

and get

enter image description here

Is there an "elegant" way to give PlotStyle to the curve with a==0, for example?

$\endgroup$
2
  • $\begingroup$ Add the option PlotStyle->{Default,Thickness[0.05],Default,Default,Default}to Plot $\endgroup$
    – andre314
    Commented Nov 8, 2017 at 22:15
  • $\begingroup$ @andre Thanks. I edited my question to explain it better. $\endgroup$ Commented Nov 8, 2017 at 22:24

1 Answer 1

1
$\begingroup$
Plot[  
    Evaluate[ Table[
       If[-0.01<a<0.01 ,Style[pfun[a][t],Thickness[0.02]],pfun[a][t]],
       {a, -1, 1, .1} 
       ]] ,
    {t, 0, 1},
    PlotRange -> All,
    PlotStyle -> Thick]  

enter image description here

$\endgroup$
3
  • $\begingroup$ I modified your suggestion as Plot[Evaluate[Table[If[a == 0,Style[pfun[a][t], Thick], Style[pfun[a][t], Dashed]], {a, -1, 1, .1}]], {t, 0, 1},PlotRange -> All] to show the curve for a==0 thick and the other dashed. Thanks $\endgroup$ Commented Nov 8, 2017 at 23:05
  • $\begingroup$ @resanrom I wouldn't use a==0 because of some eventual problems of precision. I think it's safer to use a interval like -0.01<a<0.01or Abs[a]<0.01. (0.01 or 1E-3 ...1E-6, I don't know) $\endgroup$
    – andre314
    Commented Nov 8, 2017 at 23:52
  • $\begingroup$ If you had used 1/10 instead of .1 in the step size for Table[], then @resanrom's suggestion would have been reasonable. $\endgroup$ Commented Nov 9, 2017 at 0:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.