Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #8132 > unrolled thread
| Started by | Chris Young <cy56@comcast.net> |
|---|---|
| First post | 2012-01-24 10:13 +0000 |
| Last post | 2012-01-27 11:14 +0000 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Plotting in nested Manipulates Chris Young <cy56@comcast.net> - 2012-01-24 10:13 +0000
Re: Plotting in nested Manipulates A Retey <awnl@gmx-topmail.de> - 2012-01-25 12:15 +0000
Re: Plotting in nested Manipulates Chris Young <cy56@comcast.net> - 2012-01-27 11:14 +0000
| From | Chris Young <cy56@comcast.net> |
|---|---|
| Date | 2012-01-24 10:13 +0000 |
| Subject | Plotting in nested Manipulates |
| Message-ID | <jfm07i$jtb$1@smc.vnet.net> |
I can get this to work:
Clear[c];
Manipulate[
With[
{
values = Table[c[i], {i, 1, n}],
controls = Sequence @@ Table[{{c[i], 0.5}, 0, 1, 0.1}, {i, 1, n}]
},
Manipulate[
Column[{values, ListLinePlot[Evaluate @ values]}],
controls
]
],
{n, 4, 10, 1}
]
But when I try to put the plot into the "values" variable, nothing happens.
Clear[c];
Manipulate[
With[
{
contents =
With[{values = Table[c[i], {i, 1, n}]},
Column[{values, ListLinePlot[Evaluate @ values]}]
],
controls = Sequence @@ Table[{{c[i], i * 0.1}, 0, 1, 0.1}, {i, 1, n}]
},
Manipulate[
contents,
controls
]
],
{n, 4, 10, 1}
]
Is "With" the wrong thing to use for this? I didn't have any better
luck with Module.
Chris Young
cy56@comcast.net
[toc] | [next] | [standalone]
| From | A Retey <awnl@gmx-topmail.de> |
|---|---|
| Date | 2012-01-25 12:15 +0000 |
| Message-ID | <jforpv$6f9$1@smc.vnet.net> |
| In reply to | #8132 |
Am 24.01.2012 11:13, schrieb Chris Young:
> I can get this to work:
>
> Clear[c];
>
> Manipulate[
> With[
> {
> values = Table[c[i], {i, 1, n}],
> controls = Sequence @@ Table[{{c[i], 0.5}, 0, 1, 0.1}, {i, 1, n}]
> },
>
> Manipulate[
> Column[{values, ListLinePlot[Evaluate @ values]}],
> controls
> ]
>
> ],
> {n, 4, 10, 1}
> ]
>
> But when I try to put the plot into the "values" variable, nothing happens.
>
> Clear[c];
>
> Manipulate[
> With[
> {
> contents =
> With[{values = Table[c[i], {i, 1, n}]},
> Column[{values, ListLinePlot[Evaluate @ values]}]
> ],
>
> controls = Sequence @@ Table[{{c[i], i * 0.1}, 0, 1, 0.1}, {i, 1, n}]
> },
>
> Manipulate[
> contents,
> controls
> ]
>
> ],
> {n, 4, 10, 1}
> ]
>
>
> Is "With" the wrong thing to use for this? I didn't have any better
> luck with Module.
I think With is o.k., you are missing a Dynamic for the ListLinePlot,
otherwise the ListLinePlot is evaluated too early, when the c[i] don't
have values yet, and it will never be updated later:
Manipulate[
With[{
contents =
With[{values = Table[c[i], {i, 1, n}]},
Column[{values, Dynamic[ListLinePlot[values]]}]
],
controls = Sequence @@ Table[{{c[i], i*0.1}, 0, 1, 0.1}, {i, 1, n}]
},
Manipulate[contents, controls]],
{n, 4, 10, 1}
]
Now if you wonder why that is not necessary for the values in the first
row of Column: ListLinePlot is a function that generates a Graphics, and
that Graphics will not contain any of the c[i] anymore, since
ListLinePlot dismissed the nonnumerical values. The following will
create the graphics directly, and thus will be happy without the Dynamic:
Clear[c];
Manipulate[
With[{
contents = With[{values = Table[c[i], {i, 1, n}]},
Column[{
values,
Graphics[{Blue,
Line[Table[{k, values[[k]]}, {k, Length[values]}]]},
Frame -> True, AspectRatio -> 1/GoldenRatio]
}]
],
controls = Sequence @@ Table[{{c[i], i*0.1}, 0, 1, 0.1}, {i, 1, n}]
},
Manipulate[contents, controls]],
{n, 4, 10, 1}
]
hth,
albert
[toc] | [prev] | [next] | [standalone]
| From | Chris Young <cy56@comcast.net> |
|---|---|
| Date | 2012-01-27 11:14 +0000 |
| Message-ID | <jfu0uc$c8q$1@smc.vnet.net> |
| In reply to | #8166 |
Thanks very much, that fixes the problem.
On 2012-01-25 12:15:59 +0000, A Retey said:
> I think With is o.k., you are missing a Dynamic for the ListLinePlot,
> otherwise the ListLinePlot is evaluated too early, when the c[i] don't
> have values yet, and it will never be updated later:
>
> Manipulate[
> With[{
> contents =
> With[{values = Table[c[i], {i, 1, n}]},
> Column[{values, Dynamic[ListLinePlot[values]]}]
> ],
> controls = Sequence @@ Table[{{c[i], i*0.1}, 0, 1, 0.1}, {i, 1, n}]
> },
> Manipulate[contents, controls]],
> {n, 4, 10, 1}
> ]
>
> Now if you wonder why that is not necessary for the values in the first
> row of Column: ListLinePlot is a function that generates a Graphics, and
> that Graphics will not contain any of the c[i] anymore, since
> ListLinePlot dismissed the nonnumerical values. The following will
> create the graphics directly, and thus will be happy without the Dynamic:
>
> Clear[c];
>
> Manipulate[
> With[{
> contents = With[{values = Table[c[i], {i, 1, n}]},
> Column[{
> values,
> Graphics[{Blue,
> Line[Table[{k, values[[k]]}, {k, Length[values]}]]},
> Frame -> True, AspectRatio -> 1/GoldenRatio]
> }]
> ],
> controls = Sequence @@ Table[{{c[i], i*0.1}, 0, 1, 0.1}, {i, 1, n}]
> },
> Manipulate[contents, controls]],
> {n, 4, 10, 1}
> ]
>
>
> hth,
>
> albert
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web