       Re: ListPlot Problem

• To: mathgroup at smc.vnet.net
• Subject: [mg92911] Re: ListPlot Problem
• From: "Youness Eaidgah" <y.eaidgah at gmail.com>
• Date: Sat, 18 Oct 2008 06:25:02 -0400 (EDT)

```Thank you all for your replies, specially Szabolcs with a great solution.
I modified my program as below. I also add a line to fit a curve to the
data. But, as before, I got some difficulties with "Dynamic".

Clear[x, a, b, c, d, f]

a = (8000*35 - 4000*(65 - x))*0.11 + (10000*35 -
2000*(65 - x))*0.11 + (12000*100 -
12000*65)*0.28 + (12000*100 - 12000*65)*0.22 + (12000*100 -
12000*65)*0.18 + (12000*100 - 12000*65)*0.1;

b = (8000*100 + 6000*x - 14000*65)*0.11 + (10000*100 + 4000*x -
14000*65)*0.11 + (12000*100 + 2000*x -
14000*65)*0.28 + (14000*100 - 14000*65)*0.22 + (14000*100 -
14000*65)*0.18 + (14000*100 - 14000*65)*0.1;

c = (8000*100 + 8000*x - 16000*65)*0.11 + (10000*100 + 6000*x -
16000*65)*0.11 + (12000*100 + 4000*x -
16000*65)*0.28 + (14000*100 + 2000*x -
16000*65)*0.22 + (16000*100 - 16000*65)*0.18 + (16000*100 -
16000*65)*0.1;

d = (8000*100 + 10000*x - 18000*65)*0.11 + (10000*100 + 8000*x -
18000*65)*0.11 + (12000*100 + 6000*x -
18000*65)*0.28 + (14000*100 + 4000*x -
18000*65)*0.22 + (16000*100 + 2000*x -
18000*65)*0.18 + (18000*100 - 18000*65)*0.1;

f = {{12000, a}, {14000, b}, {16000, c}, {18000, d}};

{Slider[Dynamic[x], {0, 70, 0.5}], Dynamic[x]}

Dynamic[ListPlot[f, Joined -> True]]

f1 = Fit[f, {1, y, y^2}, y]

Dynamic[Plot[f1, {y, 12000, 18000}]]

As I change the value of x by slider, the Plot(last line of program) dose
not get updated. Also, If i wrap Dynamic around the Fit, I face my last
problem again. I am wondering if there is anyway to make it work, by
changing the value of x fitted curve and its plot both get updated.
Best regards,
Youness Eaidgah

On Fri, Oct 17, 2008 at 7:44 PM, Szabolcs Horv=E1t <szhorvat at gmail.com> wro=
te:

> Youness Eaidgah wrote:
>
>> Dear Masters,
>> I wrote the following simple program to make a ListPlot, but it dose not
>> work:
>>
>> In:= Clear[x, a, b, c, d]
>>
>> In:= a =
>>  N[Dynamic[
>>   Simplify[(8000*35 - 4000*(65 - x))*0.11 + (10000*35 -
>>        2000*(65 - x))*0.11 + (12000*100 -
>>        12000*65)*0.28 + (12000*100 - 12000*65)*0.22 + (12000*100 -
>>        12000*65)*0.18 + (12000*100 - 12000*65)*0.1]], 10]
>> In:= b =
>>  Dynamic[Simplify[(8000*100 + 6000*x - 14000*65)*0.11 + (10000*100 +
>>        4000*x - 14000*65)*0.11 + (12000*100 + 2000*x -
>>        14000*65)*0.28 + (14000*100 - 14000*65)*0.22 + (14000*100 -
>>        14000*65)*0.18 + (14000*100 - 14000*65)*0.1]];
>>
>> In:= c =
>>  Dynamic[Simplify[(8000*100 + 8000*x - 16000*65)*0.11 + (10000*100 +
>>        6000*x - 16000*65)*0.11 + (12000*100 + 4000*x -
>>        16000*65)*0.28 + (14000*100 + 2000*x -
>>        16000*65)*0.22 + (16000*100 - 16000*65)*0.18 + (16000*100 -
>>        16000*65)*0.1]];
>>
>> In:= d = Dynamic[Simplify[
>>    (8000*100 + 10000*x - 18000*65)*0.11 + (10000*100 + 8000*x -
>>        18000*65)*0.11 + (12000*100 + 6000*x -
>>        18000*65)*0.28 + (14000*100 + 4000*x -
>>        18000*65)*0.22 + (16000*100 + 2000*x -
>>        18000*65)*0.18 + (18000*100 - 18000*65)*0.1]];
>>
>> In:= f = {{12000, a}, {14000, b}, {16000, c}, {18000, d}}
>>
>> x= 10;
>>
>> In:= ListPlot[{f}]
>>
>> and surprisingly i get no plot and also no error message, just a chart
>> without any point on it!! I have worked on it for a while, reading the
>> list
>> plot options, but I am not able to get out of the mess. I would apprecia=
te
>> if you could help me out.
>> Bests,
>> Jonas
>>
>
> Trying to use Dynamic as a value is a common mistake.  Dynamic cannot be
> used as a value: it is simply *displayed* as the (dynamically updated) va=
lue
> of the expression it wraps.
>
> The solution: take the dynamic outside the ListPlot:
>
> a := (8000*35 - 4000*(65 - x))*0.11 + (10000*35 -
>     2000*(65 - x))*0.11 + (12000*100 - 12000*65)*0.28 + (12000*100 -
>     12000*65)*0.22 + (12000*100 - 12000*65)*0.18 + (12000*100 -
>     12000*65)*0.1
>
> b := (8000*100 + 6000*x - 14000*65)*0.11 + (10000*100 + 4000*x -
>     14000*65)*0.11 + (12000*100 + 2000*x -
>     14000*65)*0.28 + (14000*100 - 14000*65)*0.22 + (14000*100 -
>     14000*65)*0.18 + (14000*100 - 14000*65)*0.1
>
> c := (8000*100 + 8000*x - 16000*65)*0.11 + (10000*100 + 6000*x -
>     16000*65)*0.11 + (12000*100 + 4000*x -
>     16000*65)*0.28 + (14000*100 + 2000*x -
>     16000*65)*0.22 + (16000*100 - 16000*65)*0.18 + (16000*100 -
>     16000*65)*0.1
>
> d := (8000*100 + 10000*x - 18000*65)*0.11 + (10000*100 + 8000*x -
>     18000*65)*0.11 + (12000*100 + 6000*x -
>     18000*65)*0.28 + (14000*100 + 4000*x -
>     18000*65)*0.22 + (16000*100 + 2000*x -
>     18000*65)*0.18 + (18000*100 - 18000*65)*0.1
>
> f = {{12000, a}, {14000, b}, {16000, c}, {18000, d}};
>
> Dynamic@ListPlot[f]
>
> I hope this helps,
> Szabolcs
>

```

• Prev by Date: Re: ListPlot Problem
• Next by Date: notation using # with exponents and &
• Previous by thread: Re: ListPlot Problem
• Next by thread: Re: labeling axes in a ContourPlot