Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: Tag Times Protected with Show[]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg89368] Re: Tag Times Protected with Show[]
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Sat, 7 Jun 2008 02:59:16 -0400 (EDT)

On 6/6/08 at 6:45 AM, FreeCaptive6914 at gmail.com wrote:

>Hi all.  I'm updating an old program to Mathematica 6 and I get the
>error message "Tag Times in (*shows a blank graph*) is Protected."
>Here's the code.

>line = Plot[secondfit, {x, 0.8, maxtime}, DisplayFunction ->
>Identity];
>splot = ListPlot[second, PlotRange -> All, DisplayFunction ->
>Identity];
>Show[splot, line]

>secondfit is a valid function from Fit[], maxtime is a real number,
>and second is a valid list.  I've tried plotting line and splot
>individually, but I get the same error.  Ideas?

It would be useful if you showed the code used to define
secondfit and second. Having said that, you don't need to use
the DisplayFunction option with version 6.

I am guessing you are trying to fit some data and show a plot of
the data with the fitted curve along the lines of:

data = Sort[RandomReal[1, {20}]];

line = Fit[data, {1, x}, x]

0.045389 x-0.0358646

linePlot = Plot[line, {x, 1, 20}];
dataPlot = ListPlot[data];
Show[dataPlot, linePlot]

One other thing. I find FindFit to be more flexible than Fit
particularly as it allows for different Norm functions or
different minimization algorithms. So, my preference would be to
code the task above as

data = Sort[RandomReal[1, {20}]];
model= m x+b;
parameters= {m,b}

line = model/.FindFit[data, model, paramters, x]

0.045389 x-0.0358646

linePlot = Plot[line, {x, 1, 20}];
dataPlot = ListPlot[data];
Show[dataPlot, linePlot]

Separating the definition for model and parameters from the
fitting operation makes it possible to try other models without
changing the code doing the fitting.


  • Prev by Date: Re: Why don't my plots appear? My 5.2 code no longer works correctly in 6.0
  • Next by Date: Re: Adding markers on the surface of a Plot3D?
  • Previous by thread: Re: Tag Times Protected with Show[]
  • Next by thread: Why don't my plots appear? My 5.2 code no longer works correctly in 6.0