Re: Manipulate Using Listplot
- To: mathgroup at smc.vnet.net
- Subject: [mg99280] Re: [mg99250] Manipulate Using Listplot
- From: "David Park" <djmpark at comcast.net>
- Date: Sat, 2 May 2009 05:55:13 -0400 (EDT)
- References: <7225781.1241171156021.JavaMail.root@n11>
Here is one method that dispenses with both ListPlot and Manipulate and
builds the graphic directly. The routine, element, defines how each value
will be represented.
v1 = Table[Random[], {50}];
v2 = Table[Random[], {50}];
element[points_][i_] :=
Module[{val = Part[points, i], color, marker},
If[val >= 0,
color = Green; marker = Style["+", Medium],
color = Red; marker = Style["-", Medium]];
{color, Line[{{i, 0}, {i, val}}], Black, Text[marker, {i, val}]}];
Module[
{a = .0, b = .0,
pointvals, calcAll, i},
calcAll[c1_, c2_] := (pointvals = c1 v1 + c2 v2);
calcAll[a, b];
Column[
{Row[{"Param 1 ",
Slider[Dynamic[a, (a = #; calcAll[a, b]) &], {-.1, .1, .01},
Appearance -> "Labeled"]}],
Row[{"Param 2 ",
Slider[Dynamic[b, (b = #; calcAll[a, b]) &], {-.1, .1, .01},
Appearance -> "Labeled"]}],
Dynamic@
Graphics[{
Table[element[pointvals][i], {i, 1, 50}]},
AspectRatio -> 1/GoldenRatio,
Axes -> True,
PlotRange -> {-.15, .15},
ImageSize -> 450]}](* Column *)
]
David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/
From: Richard Palmer [mailto:rhpalmer at gmail.com]
Here is some sample code that uses Manipulate with ListPlot
v1 = Table[Random[], {50}];
v2 = Table[Random[], {50}];
fn[a_, b_] := a v1 + b v2
f[n_] := If[n >= 0, "+", "-"]
Manipulate[
ListPlot[fn[a, b], Filling -> Axis, PlotRange -> {-.15, .15},
PlotMarkers -> {Automatic, Medium},
FillingStyle -> {Red, Green}], {{a, 0, "Param 1"}, -.1, .1, .01,
Appearance -> "Labeled"}, {{b, 0, "Param 2"}, -.1, .1, .01,
Appearance -> "Labeled"}]
I would like to do things with the markers {color differently when positive,
change to "+" when positive, use labels rather than "dots", ...}
Is this possible? Are there some simple examples of this. Have not been
able to find in the documentation.
--
Richard Palmer
Home 508 877-3862
Cell 508 982-7266