Re: how to plot new data points to pre-existing figure
- To: mathgroup at smc.vnet.net
- Subject: [mg122876] Re: how to plot new data points to pre-existing figure
- From: Peter Pein <petsie at dordos.net>
- Date: Mon, 14 Nov 2011 07:06:02 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <j9o3j9$15$1@smc.vnet.net>
Am 13.11.2011 10:45, schrieb tle:
> Hi,
>
> Could someone please tell me how to delete the old figure and create a new one in a for loop.
>
> thanks,
>
> testPlot[k_] := Module[{i, n, m, z},
> z[x_, m_] = m*x;
> For[i = 1, i< k,
> Print[{i}];
> plot1 =
> Plot[z[x, i], {x, 0, 10}, PlotRange -> {{0, 10}, {0, 20}}];
> Print[plot1];
> i++];
> ]
>
Try PrintTemporary:
testPlot[k_] :=
Module[{i, n, m, z, tmp = PrintTemporary[""], plot1},
z[x_, m_] = m*x;
For[i = 1, i < k,
plot1 =
Plot[z[x, i], {x, 0, 10}, PlotRange -> {{0, 10}, {0, 20}},
PlotLabel -> Style["i == " <> ToString[i], 12]];
NotebookDelete[tmp];
tmp = PrintTemporary[plot1];
Pause[1];
i++];
plot1
]
testPlot[3]