Normally, Plot
acts like a black box and only gives you the requested plot once it has finished computing it.
However it can be useful, other than interesting, to see the unfinished plot in the act of being built. For example to get an immediate, rough idea of how a function behaves, without having to wait for the whole detailed graph to be computed.
How can I make Plot (or some other function) act like this?
I can simulate a similar behaviour using some loop which increases step by step the MaxRecursion
option and shows each result, but this would require a lot more computational time because at each new value of MaxRecursion Plot would recompute all the previous recursions.
I can also make a "progressive plot" generating the list of point with something like
out={};Do[AppendTo[out,{x,x^2}],{x,0,10,0.1}];
Dynamic@ListPlot[out]
but this is no good either because I can't efficiently use recursion steps like Plot does and it gets slower and slower at increasing x values, probably because of the AppendTo creating a larger and larger list.
I looked around at options like EvaluationMonitor
and StepMonitor
but I didn't manage to understand how to use them for this purpose.
Dynamic
. As a workaround I added a variable which is changed as well and which triggers the expression in Dynamic, but I'd love to know if there is a cleaner way $\endgroup$