0

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;
  Plotsprt`MainPlotsprt[dt, conver, tfinal]
Erdem
  • 869
  • 4
  • 11
  • 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 08: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 08: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 08:43
  • That is a huge weakness. – Erdem Apr 23 '18 at 11:06
  • I know: https://mathematica.stackexchange.com/q/46746/5478 – Kuba Apr 23 '18 at 11:25

0 Answers0