3
$\begingroup$

I have a ListLinePlot with 40,000 points. When it's displayed on-screen the input fields are not responsive (text appears slowly well after the user is done typing). The code looks something like this:

DynamicModule[{plot, var},
Column[{
    InputField[Dynamic[var],String],
    Dynamic[Refresh[plot, None]]
}],
Initialization :> (plot = makePlot[])
]

makePlot[] := ListLinePlot[{#, Sin[#] + RandomReal[0.1]} & /@ 
    Subdivide[0, 10, 40000], ImageSize -> 500]

So even when I use Refresh[plot, None] it still causes the InputField to suffer. I'd prefer to use TrackedSymbols :> {plot} so that it can be updated when I need it to.

I've worked around this by resampling the plot and displaying fewer points. Also, rasterizing the plot works, but that's not really what I want to do. Is there a good way to control the Notebook frontend so that the displayed plot is not impacting other elements around it?

$\endgroup$
5
  • 1
    $\begingroup$ Sooner or later (depends on a machine too) the amount of boxes in a notebook will affect the performance, probably of a whole notebook. It takes more effort but is often a good idea to really work with gutted versions of big plots / images to improve performance. You can still add interactivity on top of a rasterized background. How this case can be improved depends on what exactly are you doing. $\endgroup$
    – Kuba
    Sep 9, 2019 at 11:19
  • $\begingroup$ Thanks for the reply, @Kuba. Correct me if I'm wrong, but it seems other frameworks don't have this issue - like Plotly in JavaScript. Is this because behind the scenes those frameworks are already optimizing what's shown? Perhaps the "rigor" of Mathematica allows for graphical overload on purpose. Is there a good Option to use with ListLinePlot to improve the efficiency of the plot? $\endgroup$ Sep 9, 2019 at 12:00
  • $\begingroup$ One thing to try before drastic changes is to do Graphics+Line to make sure that only essentials are there. I do not know much about this issue in other frameworks. At some point vector grafics have that problem, there are comercial JS packages that serve exactly this purpose. $\endgroup$
    – Kuba
    Sep 9, 2019 at 12:29
  • $\begingroup$ Which version are you using? $\endgroup$
    – Edmund
    Sep 10, 2019 at 23:30
  • $\begingroup$ 12.0 also have access to 12.1 beta $\endgroup$ Sep 12, 2019 at 1:37

0

Your Answer

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

Browse other questions tagged or ask your own question.