Adaptive Sampling of 2D Graphics

First, we start with a simple plot.

gr=Plot[Sin[x]^2+Sqrt[x],{x,0,π},Mesh->All];

Now, we extract out all of the points.

allpts=Sort[Cases[Normal[gr],_Point,Infinity][[All,1]]];

Next, extract a subset of the points and Map a Line primitive around each point.  In this case, every fifth point.

Finally, we do a ListPlot of the sampled points and also combine this with the Line primitives.

Show[ListPlot[allpts,Joined->If[#===None,True,False],Frame->{True,True,False,False},ImageSize->600,PlotRange->{{0,3},{0,3}},FrameLabel->{"x","y"},PlotLabel->Grid[{{Text["Adaptive Sampling"]},{TraditionalForm[Sin[x]^2+Sqrt[x]]}}],Mesh->#,PlotStyle->Orange,FillingStyle->Gray,PlotTheme->None,Filling->If[#===None,None,Axis]]&/@{None,All}]

Animation

Here, we simply insert a phase shift into the Sin term and vary the phase shift from 0 to 2 π.

anim=Table[
gr=Plot[Sin[x-t]^2+Sqrt[x],{x,0,π},Mesh->All];allpts=Sort[Cases[Normal[gr],_Point,Infinity][[All,1]]];Show[ListPlot[allpts,Joined->If[#===None,True,False],Mesh->#,PlotStyle->Orange,FillingStyle->Gray,PlotTheme->None,Filling->If[#===None,None,Axis]]&/@{None,All},Frame->{True,True,False,False},ImageSize->300,PlotRange->{{0,3},{0,3}},FrameLabel->{"x","y"},PlotLabel->Grid[{{Text["Adaptive Sampling"]},{TraditionalForm[Sin[x-θ]^2+Sqrt[x]]}}]],{t,0,2 π,.1}];

SetDirectory[NotebookDirectory[]];

Export["adaptive.mp4",anim]