Group Abstract Group Abstract

Message Boards Message Boards

Combine Plots into one using a loop?

Posted 7 years ago
Attachments:
POSTED BY: Betty Boo
11 Replies

We can use the additional option AspectRatio -> Automatic

Plot[sol, {t, -4, 8}, PlotRange -> All, PlotStyle -> Automatic, 
 AxesStyle -> Thickness[.001], LabelStyle -> {Black, Medium}, 
 AxesOrigin -> {0, -10}, AspectRatio -> Automatic]

traj1

sol = Table[
   NDSolveValue[{D[xtraj[t], 
       t] == -(Sinh[2 xtraj[t] (-t)]/(Cosh[2 xtraj[t] (-t)])), 
     xtraj[0] == n}, xtraj[t], {t, -4, 8}], {n, -1, 2.75, .25}];
Plot[sol, {t, -4, 8}, PlotRange -> All, PlotStyle -> Automatic, 
 AxesStyle -> Thickness[.001], LabelStyle -> {Black, Medium}, 
 AxesOrigin -> {0, -10}]

traj

This?

code

Download the notebook for the code.

Attachments:
POSTED BY: Shenghui Yang

Are you asking about excluding a range of y values when plotted or when integrated? Your question is not clear.

To restrict your plot you can use RegionFunction:

Plot[sol, {t, -4, 8}, PlotRange -> All, PlotStyle -> Automatic, 
 AxesStyle -> Thickness[.001], LabelStyle -> {Black, Medium}, 
 AxesOrigin -> {0, -10}, AspectRatio -> Automatic, 
 RegionFunction -> Function[{x, y}, (y > -2) && (y < 2)]]

to get

enter image description here

POSTED BY: Neil Singer
Posted 7 years ago

Interesting code but it's not quite what I wanted - thanks.

POSTED BY: Betty Boo

Is there anything like this?

sol1 = Table[
  NDSolveValue[{D[xtraj[t], 
      t] == -(Sinh[2 xtraj[t] (-t)]/(Cosh[2 xtraj[t] (-t)])), 
    xtraj[0] == n}, xtraj[t], {t, -4, 8}], {n, -.1, .1, .02}]; p1 = 
 Plot[sol1, {t, -4, 8}, PlotRange -> {{-1, 1}, {-.15, .15}}, 
  PlotStyle -> Automatic, AxesStyle -> Thickness[.001], 
  LabelStyle -> {Black, Medium}, 
  PlotLegends -> Table[n, {n, -.1, .1, .02}]]
Posted 7 years ago

I have another question - how can I restrict the domain such that:

-0.1> xtraj[t]> 0.1

Any help would be much appreciated.

POSTED BY: Betty Boo
Posted 7 years ago

How about reversing the plot?

POSTED BY: Betty Boo
Posted 7 years ago

That looks much better :-) thank you!

POSTED BY: Betty Boo
Posted 7 years ago

The problem with this one is that the x and y values are different the plot is flattened?

POSTED BY: Betty Boo
Posted 7 years ago

Thanks.

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