0
$\begingroup$

I have a complicated function and my computer crashes when I try to plot it using ListPlot from 0 to 30.

So what I want to do is instead of plotting the function from 0 to 30, I cut it into segments, i.e. 0 to 3, 3 to 6, and so on, then I want to combine all these segments.

How do I combine these segments?

Thank you

$\endgroup$
5
  • $\begingroup$ Do you understand why it crashes? $\endgroup$
    – mikado
    Oct 17, 2016 at 5:34
  • $\begingroup$ I think my computer crashes because it ran out of memory $\endgroup$
    – anonymous
    Oct 17, 2016 at 5:40
  • $\begingroup$ This is how to do what you asked. list1 = Table[{x, x^2}, {x,0,3}]; list2 = Table[{x, x^2}, {x,3,6}]; list3 = Table[{x, x^2}, {x,6,9}]; ListPlot[{list1, list2, list3}] but I question whether that will really solve your problem. $\endgroup$
    – Bill
    Oct 17, 2016 at 5:59
  • $\begingroup$ I tried this and it works. Thanks! How do I make the different segments into the same color and linestyle? $\endgroup$
    – anonymous
    Oct 17, 2016 at 6:01
  • $\begingroup$ Study this hint: ListPlot[{list1, list2, list3}, PlotStyle -> Red] $\endgroup$
    – Bill
    Oct 17, 2016 at 6:11

2 Answers 2

0
$\begingroup$

You can use Show with PlotRange->All

plots = Table[ListPlot[Table[{x, Sin[x]}, {x, a, a + 2, 0.1}], 
                       PlotStyle -> Hue[a/10]], {a, 0, 6, 2}]

enter image description here

Show[plots, PlotRange -> All]

enter image description here

$\endgroup$
0
$\begingroup$

You could also try to build lines from values and then use Show@Graphics[{specifications, lines}, options], which I think gives you more control. Table[ ] would also let you use a larger step so you do not run into memory issues. For example line1=Line@Table[{z,function[z]}, {z, min, max, step}] plt1=Show@Graphics[{ Dashing[.02], Black, line1 },Axes->True]

$\endgroup$

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.