Skip to main content
added 2 characters in body
Source Link
kglr
  • 403.4k
  • 18
  • 501
  • 959

Combinining consecutive Lines into a single lineLine and moving the function definitions to Initialization (as suggested by @m_goldberg)

Combinining consecutive Lines into a single line and moving the function definitions to Initialization (as suggested by @m_goldberg)

Combinining consecutive Lines into a single Line and moving the function definitions to Initialization (as suggested by @m_goldberg)

added 186 characters in body
Source Link
kglr
  • 403.4k
  • 18
  • 501
  • 959
Manipulate[MapAt[# /. {x__, lines : Line[_] ..} :> {x,Line[Join @@ ({lines}[[All, 1]])]} &, Plot[{y0[t], yT[t]}, {t, -3, 7}, Exclusions ->  {t == 1, t == 0.5, t == -10.5 + t0, t == 1 + t0}, (* addedwith few more exclusions *) PlotStyle -> {{Thick, Black}}, PlotRange -> {0, 3}, Frame -> True, Axes -> False, ImageSize -> 1.2 {500, 330}, BaseStyle -> {FontSize -> 16}, FrameLabel -> {t, x}, RotateLabel -> False, PlotRangePadding -> {{2, 0}, {.1, .1}}, Epilog -> {PointSize[0.015], Red, Dashed, Line[{{-4, y0[s]}, {s, y0[s]}}], Point[{{-4, y0[s]}, {s, y0[s]}, {s + t0, yT[s + t0]}}], Black, Dashing[{}], Line[{{-4, 0}, {-4, 3}}], Red, Point[{-4, yT[s]}], Black, Arrowheads[.03], Arrow[{{-4, 3}, {-4, 3.1}}], Red, Dashing[{}], Line[{{s, y0[s]}, {s + t0, yT[s + t0]}}]}], {1}] , {{t0, 2}, -2, 5, 0.01}, {{s, 0}, -2, 0.67, 0.01}, Initialization :> (y[t_, t0_] := 1/(1 - (t - t0)); y0[x_] := y[x, 0]; yT[x_] := y[x, t0])] 

Before (with Plot[...] instead of MapAt[..., Plot[...], ...]):

enter image description here

After:

enter image description here

Manipulate[MapAt[# /. {x__, lines : Line[_] ..} :> {x,Line[Join @@ ({lines}[[All, 1]])]} &, Plot[{y0[t], yT[t]}, {t, -3, 7}, Exclusions -> {t == 1, t == 0, t == -1, t == 1 + t0}, (* added few more exclusions *) PlotStyle -> {{Thick, Black}}, PlotRange -> {0, 3}, Frame -> True, Axes -> False, ImageSize -> 1.2 {500, 330}, BaseStyle -> {FontSize -> 16}, FrameLabel -> {t, x}, RotateLabel -> False, PlotRangePadding -> {{2, 0}, {.1, .1}}, Epilog -> {PointSize[0.015], Red, Dashed, Line[{{-4, y0[s]}, {s, y0[s]}}], Point[{{-4, y0[s]}, {s, y0[s]}, {s + t0, yT[s + t0]}}], Black, Dashing[{}], Line[{{-4, 0}, {-4, 3}}], Red, Point[{-4, yT[s]}], Black, Arrowheads[.03], Arrow[{{-4, 3}, {-4, 3.1}}], Red, Dashing[{}], Line[{{s, y0[s]}, {s + t0, yT[s + t0]}}]}], {1}] , {{t0, 2}, -2, 5, 0.01}, {{s, 0}, -2, 0.67, 0.01}, Initialization :> (y[t_, t0_] := 1/(1 - (t - t0)); y0[x_] := y[x, 0]; yT[x_] := y[x, t0])] 
Manipulate[MapAt[# /. {x__, lines : Line[_] ..} :> {x,Line[Join @@ ({lines}[[All, 1]])]} &, Plot[{y0[t], yT[t]}, {t, -3, 7}, Exclusions ->  {t == 1, t == 0.5, t == 0.5 + t0, t == 1 + t0}, (* with few more exclusions *) PlotStyle -> {{Thick, Black}}, PlotRange -> {0, 3}, Frame -> True, Axes -> False, ImageSize -> 1.2 {500, 330}, BaseStyle -> {FontSize -> 16}, FrameLabel -> {t, x}, RotateLabel -> False, PlotRangePadding -> {{2, 0}, {.1, .1}}, Epilog -> {PointSize[0.015], Red, Dashed, Line[{{-4, y0[s]}, {s, y0[s]}}], Point[{{-4, y0[s]}, {s, y0[s]}, {s + t0, yT[s + t0]}}], Black, Dashing[{}], Line[{{-4, 0}, {-4, 3}}], Red, Point[{-4, yT[s]}], Black, Arrowheads[.03], Arrow[{{-4, 3}, {-4, 3.1}}], Red, Dashing[{}], Line[{{s, y0[s]}, {s + t0, yT[s + t0]}}]}], {1}] , {{t0, 2}, -2, 5, 0.01}, {{s, 0}, -2, 0.67, 0.01}, Initialization :> (y[t_, t0_] := 1/(1 - (t - t0)); y0[x_] := y[x, 0]; yT[x_] := y[x, t0])] 

Before (with Plot[...] instead of MapAt[..., Plot[...], ...]):

enter image description here

After:

enter image description here

Source Link
kglr
  • 403.4k
  • 18
  • 501
  • 959

Combinining consecutive Lines into a single line and moving the function definitions to Initialization (as suggested by @m_goldberg)

Manipulate[MapAt[# /. {x__, lines : Line[_] ..} :> {x,Line[Join @@ ({lines}[[All, 1]])]} &, Plot[{y0[t], yT[t]}, {t, -3, 7}, Exclusions -> {t == 1, t == 0, t == -1, t == 1 + t0}, (* added few more exclusions *) PlotStyle -> {{Thick, Black}}, PlotRange -> {0, 3}, Frame -> True, Axes -> False, ImageSize -> 1.2 {500, 330}, BaseStyle -> {FontSize -> 16}, FrameLabel -> {t, x}, RotateLabel -> False, PlotRangePadding -> {{2, 0}, {.1, .1}}, Epilog -> {PointSize[0.015], Red, Dashed, Line[{{-4, y0[s]}, {s, y0[s]}}], Point[{{-4, y0[s]}, {s, y0[s]}, {s + t0, yT[s + t0]}}], Black, Dashing[{}], Line[{{-4, 0}, {-4, 3}}], Red, Point[{-4, yT[s]}], Black, Arrowheads[.03], Arrow[{{-4, 3}, {-4, 3.1}}], Red, Dashing[{}], Line[{{s, y0[s]}, {s + t0, yT[s + t0]}}]}], {1}] , {{t0, 2}, -2, 5, 0.01}, {{s, 0}, -2, 0.67, 0.01}, Initialization :> (y[t_, t0_] := 1/(1 - (t - t0)); y0[x_] := y[x, 0]; yT[x_] := y[x, t0])]