Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: how to plot new data points to pre-existing figure

  • To: mathgroup at smc.vnet.net
  • Subject: [mg122891] Re: how to plot new data points to pre-existing figure
  • From: Heike Gramberg <heike.gramberg at gmail.com>
  • Date: Mon, 14 Nov 2011 07:08:45 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201111130943.EAA00009@smc.vnet.net>

You could do something like this (note that the Pause[.5] is just to slow things down a bit)

testPlot[k_] := Module[{i, z},
  z[x_, m_] := m*x;
  Monitor[For[i = 1, i < k,
    plot1 =
     Plot[z[x, i], {x, 0, 10}, PlotRange -> {{0, 10}, {0, 20}},
      ImageSize -> 300];
    Pause[.5];
    i++],
   Column[{i, plot1}]];
  Column[{i, plot1}]]

This is useful for long calculations where you want to plot the intermediate result. If you just want to animate a list of graphs, you might want to use Animate or ListAnimate e.g.

testPlot1[k_] := Module[{z},
  z[x_, m_] := m*x;
  Animate[Column[{i,
     Plot[z[x, i], {x, 0, 10}, PlotRange -> {{0, 10}, {0, 20}},
      ImageSize -> 300]}], {i, 1, k - 1, 1}]]

Heike.


On 13 Nov 2011, at 10:43, tle wrote:

> 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++];
>  ]
>




  • Prev by Date: Re: Questions about IMS 2010 in China?
  • Next by Date: Re: Generating Word Documents from Mathematica
  • Previous by thread: Re: how to plot new data points to pre-existing figure
  • Next by thread: Re: how to plot new data points to pre-existing figure