# Updating a separate window plot without redrawing it

This is really easy in Matlab but I am having a hard time to find an equivalent in Mathematica. I am simply trying to create a convergence plot that I want to add one point in every time step, of course, I don't want to keep redrawing the plot since I might end up having 100000 points in there. I found a solution to have the plot in a separate window but not able stop redrawing it.

BeginPackage["Plotsprt"];
MainPlotsprt::usage=" ";
Begin["Private"];
MainPlotsprt[dt_, conver_,tfinal_]:= Module[{},
obj=CreateDocument[Dynamic[theGraphic],WindowSize->{500,500}];
\$DisplayFunction=((CreateDocument[#,obj];#)&);

Do[
conver=conver-0.0000001;

theGraphic=ListPlot[{{dt*i,Log10[conver]}},PlotRange->All],
{i,tfinal}]

Return[];
];

SetAttributes[MainPlotsprt,{HoldAll}]
End[];
EndPackage[];

(* Get[FileNameJoin[{NotebookDirectory[], "Plotsprt.wl"}]]; *)
dt = 0.1;
conver = 0.001;
tfinal = 500;
PlotsprtMainPlotsprt[dt, conver, tfinal]

• then don't modify theGraphic at each interation. Create data and once you want to show changes use theGraphic = ListPlot[data, ...]. Is this what you want?> – Kuba Apr 23 '18 at 8:21
• @Kuba My ideal approach is to insert one point to the plot in every iteration. I can create blocks of data, let's say 100 points and plot it too but I want to keep the previous 100 points on the plot. I just add 100 more points to existing plot. Removing the theGraphic makes no change. – Erdem Apr 23 '18 at 8:37
• There is no way to add points to a plot so you need to build your data table and each 100 steps you need to update theGraphics. – Kuba Apr 23 '18 at 8:43
• That is a huge weakness. – Erdem Apr 23 '18 at 11:06
• – Kuba Apr 23 '18 at 11:25