TransWikia.com

Why "Joined" does not draw all the lines?

Mathematica Asked on May 1, 2021

I’m working on a project in order to plot a graphical method for finite-difference equations called cobweb method. The next figure was succesful try for

$$x_{t+1} = Rx_t – frac{R}{2000}x_t^2$$

enter image description here

But, when I try with

$$x_{t+1} = cos{x_t},$$

and copy-paste the code I used before, the result was

enter image description here

For some reason Joined->True doesn’t draw all the lines. Changing a litle bit the number of point plotted, from 17 to 16, the figure is correct

enter image description here


There is a problem, but, where? My code is the following

difEqu[x_] := N[Cos[x]]

traFin = {{0.4,0},{0.4,0.921061},{0.921061,0.921061},{0.921061,0.604976},
 {0.604976,0.604976},{0.604976,0.822516},{0.822516,0.822516},{0.822516,0.68038},
 {0.68038,0.68038},{0.68038,0.777334},{0.777334,0.777334},{0.777334,0.712786},
 {0.712786,0.712786},{0.712786,0.756543},{0.756543,0.756543},{0.756543,0.727213},
 {0.727213,0.727213},{0.727213,0.74703},{0.74703,0.74703},{0.74703,0.73371},
 {0.73371,0.73371},{0.73371,0.742695},{0.742695,0.742695},{0.742695,0.736649},
 {0.736649,0.736649},{0.736649,0.740724},{0.740724,0.740724},{0.740724,0.73798},
 {0.73798,0.73798},{0.73798,0.739829},{0.739829,0.739829},{0.739829,0.738584}}

extremos = {{0.4,0},{0.739829,0.738584}}

Show[
 Plot[
  Evaluate[
   {Legended[Style[difEqu[x], RGBColor[0., 0., 1.], Thickness[0.004]],"x[0] = 0.6"],
   Legended[Style[x, RGBColor[0., 0., 0.], Thickness[0.004], Dashed],"Identidad"]}
  ],
 {x, 0, 1},
 PlotTheme -> "Scientific",
 ImageSize -> Large,
 PlotRange -> Full,
 FrameLabel ->
  {Style["x (t)", FontSize -> 35],
  Style["x (t+1)", FontSize -> 35]},
  LabelStyle -> {FontFamily -> "Arial", 20, RGBColor[0., 0., 0.]}
 ],
 ListPlot[
  {traFin, extremos},
  PlotStyle -> {{RGBColor[1., 0., 0.],Thickness[0.001]},{RGBColor[1., 0., 0.]}},
  Joined -> {True, False}
 ]
]

I get traFin with another code. The number of iterations here is 16, i.e.

$$x_{16+1} = underbrace{x(x(cdots(}_{text{16 times}}0.4) = 0.738584.$$


Edit: The following code corresponds to 17 iterations:

difEqu[x_] := N[Cos[x]]

traFin = {{0.4,0},{0.4,0.921061},{0.921061,0.921061},{0.921061,0.604976},{0.604976,0.604976},{0.604976,0.822516},{0.822516,0.822516},{0.822516,0.68038},{0.68038,0.68038},{0.68038,0.777334},{0.777334,0.777334},{0.777334,0.712786},{0.712786,0.712786},{0.712786,0.756543},{0.756543,0.756543},{0.756543,0.727213},{0.727213,0.727213},{0.727213,0.74703},{0.74703,0.74703},{0.74703,0.73371},{0.73371,0.73371},    {0.73371,0.742695},{0.742695,0.742695},{0.742695,0.736649},        {0.736649,0.736649},{0.736649,0.740724},{0.740724,0.740724},{0.740724,0.73798},{0.73798,0.73798},{0.73798,0.739829},{0.739829,0.739829},{0.739829,0.738584},{0.738584,0.738584},{0.738584,0.739423}}

extremos = {{0.4,0},{0.739829,0.738584}}

Show[
 Plot[
  Evaluate[
   {Legended[Style[difEqu[x], RGBColor[0., 0., 1.], Thickness[0.004]],"x[0] = 0.6"],
   Legended[Style[x, RGBColor[0., 0., 0.], Thickness[0.004], Dashed],"Identidad"]}
  ],
 {x, 0, 1},
 PlotTheme -> "Scientific",
 ImageSize -> Large,
 PlotRange -> Full,
 FrameLabel ->
  {Style["x (t)", FontSize -> 35],
  Style["x (t+1)", FontSize -> 35]},
  LabelStyle -> {FontFamily -> "Arial", 20, RGBColor[0., 0., 0.]}
 ],
 ListPlot[
  {traFin, extremos},
  PlotStyle -> {{RGBColor[1., 0., 0.],Thickness[0.001]},{RGBColor[1., 0., 0.]}},
  Joined -> {True, False}
 ]
]

One Answer

The problem you are running into is that the ListPlot is cropping the plot-region in an unlucky way. Put PlotRange->All as final option into the ListPlot call and you should be fine.

You could have found this issue yourself by inspecting the plots separately.

Correct answer by halirutan on May 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP