3
$\begingroup$

Using 11.1.0 for Linux x86 (64-bit). This should be pretty self-explanatory.

data = RandomInteger[1000, {30, 10000}];
Timing[ListLinePlot[data, PlotRange -> All];]
(*{1.752, Null}*)

Timing[ListLinePlot[data, PlotRange -> {{1000, 9000}, All}];]
(*{1.844, Null}*)

Timing[ListLinePlot[data, PlotRange -> {All, {100, 900}}];]
(*{20.66, Null}*)

Is this because a lot of disconnected lines need to be drawn? Is there a way to fix or circumvent this?

$\endgroup$

1 Answer 1

2
$\begingroup$

You can see what is going on better if you do a smaller example:

data = RandomInteger[1000, {30, 10}];
Timing[g1 = ListLinePlot[data, PlotRange -> All];]
Timing[g2 = ListLinePlot[data, PlotRange -> {All, {400, 600}}];]

Then type

FullForm[g1]

and

FullForm[g2]

As you suspected, the expression for g2 is much more involved, as there are a lot of short segments. Not only does it take a lot more memory to store all of those segments, the computer had to calculate all of those line breaks. Starts getting expensive for a large number of segments.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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