0
$\begingroup$

I have this plot but it does not do what I want it to do. I have made A MOCK-UP OUTPUT of what I want.

 ClearAll[x, xi, σ, n]
 xi = 2; k0 = 5; σ = 2;
 Show[
  Table[
   sol = NDSolve[{D[x[t], t] == (Sinh[(σ^2) x[t] (t - xi)])/((Cos[2 k0 x[t]]))), x[0] == n}, x[t], {t, 0, 4}];
  ParametricPlot[{x[t], t} /. sol, {t, 0, 4}, 
   PlotRange -> All, 
   BaseStyle -> Thick, AxesStyle -> Thickness[.001], 
   LabelStyle -> {Black, Medium}, ColorFunctionScaling -> False, 
   ColorFunction -> 
     Function[{x, y, t}, 
      Directive[
       Opacity[0.02 + (e^(-1/2 (x[t] - xi)^2 σ^2) sqrt (π/
               2) σ (1 + e^(2 x[t] (-xi) σ^2) + 
               2 e^(x[t] (-xi) σ^2) cos (2 k0 x))) /. sol[[1]] //
          First], Blue]]], {n, -3, 3 - 1/4, 1/4}]]

This is what it should output with each iteration, the curves are faded based upon the function - such that curves close to the center fade. Notice that the curve holds it opacity all through its progress.

enter image description here

$\endgroup$
  • $\begingroup$ Betty,there ar esime syntax errors in your code. For instance e^ should probably be E^ (uppercase) or Exp[...]. Similarly sqrt should be Sqrt[...]. Does it get any better if you fix those problems? I also think that your code should probably read sol = Table[...], rather than Table[sol =...]. $\endgroup$ – MarcoB Jun 4 '18 at 3:24
  • $\begingroup$ Marco not really - the output above is not something that comes from the code I'd written, it what I want to code to produce. $\endgroup$ – Betty Jun 4 '18 at 5:55
  • $\begingroup$ Did you notice that your NDSolve expression does not actually work though? If you try to evaluate it, it returns NDSolve::ndsz: At t == 9.421270636234184*^-14, step size is effectively zero; singularity or stiff system suspected.`. Until you solve this issue, you won't be able to obtain a plot no matter what. $\endgroup$ – MarcoB Jun 6 '18 at 15:37
1
$\begingroup$
functions = Table[n x^4 + n/2 x^2 + n/5, {n, -4, 4}];

styled = MapThread[
      Style[#1, Opacity@#2] &,
      {#, Abs@Standardize[#, Mean, 2 StandardDeviation[#]&]& @Range@Length@#}
   ]& @functions;

Plot[
   Evaluate@styled, {x, -0.7, 0.7},
   PlotRange -> All, PlotStyle -> Directive[Thick, Darker@Red]
]

Mathematica graphics

$\endgroup$
  • $\begingroup$ This looks right but what if I wanted to use my orginal equation - as I may want to vary it: sol = NDSolve[{D[x[t], t] == (Sinh[(σ^2) x[t] (t - xi)])/((Cos[2 k0 x[t]]))), x[0] == n}, x[t], {t, 0, 4}] $\endgroup$ – Betty Jun 4 '18 at 23:05
  • $\begingroup$ thanks for that, but in terms of my function I do not see how it can work, in fact being new to Mathematica it looks like it is only designed for this pattern. Can you please tell me more? $\endgroup$ – Betty Jun 5 '18 at 3:22
  • $\begingroup$ @Betty Did you notice that your NDSolve expression does not actually work though? If you try to evaluate it, it returns NDSolve::ndsz: At t == 9.421270636234184*^-14, step size is effectively zero; singularity or stiff system suspected.`. Until you solve this issue, you won't be able to obtain a plot no matter what. $\endgroup$ – MarcoB Jun 6 '18 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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