how to add graphics options in a plot which is already produced and has a manipulator

34 views
Skip to first unread message

Jennifer

unread,
May 29, 2012, 5:44:38 AM5/29/12
to
Hi all,

I am novice to mathematica and stuck into one problem i.e.

how can I add graphics option to an already made plot which has a manipulator to control itself.

s = Manipulate[
PopupWindow[
Graphics[
DiscretePlot[Sin[a t], {t, 0, 2 Pi, Pi/6}, ExtentSize -> Full,
ImageSize->Scaled[1], AspectRatio -> .2]], {a}],
OpenerView[{"Vertical", Control[{{a, 1, "Manipulator"}, 1, 30}]}],
ControlPlacement -> Bottom]]


Now I want to add a plot Label by calling the already produced plot s.Because I dont want the duplication of code again as I have to use 4 more different plots in a popupmenu. For eg. when I select s from popupmenu then it should give the output t

t= Show[ s, PlotLabel->"Popup Window Plot"] but this is showing error "Show::gtype: Manipulate is not a type of graphics"

djmpark

unread,
May 30, 2012, 4:11:10 AM5/30/12
to
It's a bit difficult for me to understand what your overall objective is
here but enough to perhaps give a few tips and examples.

1) You seem to be using the PopupWindow to display the parameter value in
the plot. This seems an extravagant use of a PopupWindow. Better to display
it directly, say by using a "Labeled" slider.

2) A dynamic presentation always requires a fixed background. If a plot or
curve is varying with the parameter a and the PlotRange is also varying then
it has a rather disorienting effect. This often happens for Mathematica
users because they are unaware, or forget, that unless they explicitly
specify a PlotRange, Mathematica picks one according to what it thinks are
the interesting portions of the plot and this varies as the parameter
varies.

3) Frame plots are generally better than Axis plots because they keep the
Axis, tick marks and labels off of the data. The data is always the most
important thing and other plot elements should not interfere with it. WRI
leads users into this trap because Axis plots are usually the default. If
you look at technical journals you will seldom see an Axis plot where an
axis lies over the data.

The following is a simpler Manipulate that takes these items into account:

Manipulate[
DiscretePlot[Sin[a t], {t, 0, 2 Pi, Pi/6},
ExtentSize -> Right,
ImageSize -> 500,
AspectRatio -> .2,
Frame -> True,
PlotRange -> {-1.2, 1.2}],
{a, 1, 30, Appearance -> "Labeled", ControlPlacement -> Bottom}]

Sometimes it is easier to compose a dynamic presentation by bypassing
Manipulate and writing a direct DynamicModule. Here you could have more
control over the format of the display by using Column and Row constructs.
It is also easier when you want to compute and use secondary dynamic
variables from the primary dynamic variables - those directly set by
controls. So here is a routine that generates a DynamicModule display of the
type you have, with the function and title as input parameters:

plotDisplay[func_, title_String] :=
DynamicModule[{a = 1},
Column[
{Style[title, 16, FontFamily -> "Times"],
Dynamic@DiscretePlot[func[a t], {t, 0, 2 Pi, Pi/6},
ExtentSize -> Right,
ImageSize -> 500,
AspectRatio -> .2,
Frame -> True,
PlotRange -> {-1.1, 1.1}],
Row[{
"a", Spacer[10],
Slider[Dynamic[a], {1, 30}, Appearance -> "Labeled"]}] (*
Row *)
}](* Column *)
]

The following then creates a TabView of four different plots of this type.

TabView[{
Sin -> plotDisplay[Sin, "Discrete Plot for Sin Function"],
Cos -> plotDisplay[Cos, "Discrete Plot for Cos Function"],
Sin^2 ->
plotDisplay[Sin[#]^2 &,
"Discrete Plot for \!\(\*SuperscriptBox[\(Sin\), \(2\)]\) \
Function"],
Cos^2 ->
plotDisplay[Cos[#]^2 &,
"Discrete Plot for \!\(\*SuperscriptBox[\(Cos\), \(2\)]\) \
Function"]}]


David Park
djm...@comcast.net
http://home.comcast.net/~djmpark/index.html

Szabolcs Horvát

unread,
May 31, 2012, 2:53:58 AM5/31/12
to
On 2012.05.29. 11:44, Jennifer wrote:
> Hi all,
>
> I am novice to mathematica and stuck into one problem i.e.
>
> how can I add graphics option to an already made plot which has a manipulator to control itself.
>
> s = Manipulate[
> PopupWindow[
> Graphics[
> DiscretePlot[Sin[a t], {t, 0, 2 Pi, Pi/6}, ExtentSize -> Full,
> ImageSize->Scaled[1], AspectRatio -> .2]], {a}],
> OpenerView[{"Vertical", Control[{{a, 1, "Manipulator"}, 1, 30}]}],
> ControlPlacement -> Bottom]]
>
>
> Now I want to add a plot Label by calling the already produced plot s.Because I dont want the duplication of code again as I have to use 4 more different plots in a popupmenu. For eg. when I select s from popupmenu then it should give the output t
>
> t= Show[ s, PlotLabel->"Popup Window Plot"] but this is showing error "Show::gtype: Manipulate is not a type of graphics"
>

This question has been asked on http://mathematica.stackexchange.com/ as
well, and received some answers there:

http://mathematica.stackexchange.com/questions/6121/how-to-add-graphics-options-to-an-already-produced-plot-having-manipulator

When cross-posting, let's try to link the threads together to avoid
duplication of effort. (I just included a link to this MathGroup thread
in the Mathematica.SE version of the same question.)

Mathematica.SE had a discussion about cross-posting here, in case anyone
is interested:

http://meta.mathematica.stackexchange.com/questions/367/is-there-any-special-kind-of-crossposting-netiquette-for-se-mathgroup-etc

--
Szabolcs Horv=E1t
Visit Mathematica.SE: http://mathematica.stackexchange.com/

Alexei Boulbitch

unread,
May 31, 2012, 2:47:51 AM5/31/12
to
Hi all,

I am novice to mathematica and stuck into one problem i.e.

 how can I add graphics option to an already made plot which has a
manipulator to control itself.

s = Manipulate[
  PopupWindow[
   Graphics[
    DiscretePlot[Sin[a t], {t, 0, 2 Pi, Pi/6}, ExtentSize -> Full,
     ImageSize->Scaled[1], AspectRatio -> .2]], {a}],
  OpenerView[{"Vertical", Control[{{a, 1, "Manipulator"}, 1, 30}]}],
  ControlPlacement -> Bottom]]


Now I want to add a plot Label by calling the already produced plot
s.Because  I dont want the duplication of code again as  I have to use
4  more different plots  in a popupmenu. For eg.  when I select s from
popupmenu then it should give the output t

t= Show[ s, PlotLabel->"Popup Window Plot"]  but this is showing error
 "Show::gtype: Manipulate is not a type of graphics"


Hi,
Is it the thing you need down here?

s=
Manipulate[PopupWindow[
Graphics[DiscretePlot[Sin[at],{t,0,2Pi,Pi⁄6},ExtentSize→Full,
ImageSize→Scaled[1],AspectRatio→".2",PlotRange→{-1,1},
PlotLabel→Style["My blue label",14,Bold,Blue]]],{a}],
OpenerView[{"Vertical",Control[{{a,1,"Manipulator"},1,30}]}],
ControlPlacement→Bottom]

Or this one?

sss = Manipulate[
  PopupWindow[
   Graphics[
    DiscretePlot[Sin[a t], {t, 0, 2 Pi, Pi/6}, ExtentSize -> Full,
     ImageSize -> Scaled[1], AspectRatio -> .2,
     PlotRange -> {-1, 1}]], {a}],
  OpenerView[{"Vertical", Control[{{a, 1, "Manipulator"}, 1, 30}]}],
  ControlPlacement -> Bottom];

t = Column[{
  Text[Style["My blue label", 14, Bold, Blue]],
  sss

  }, Alignment -> Center]

Have fun, Alexei

Alexei BOULBITCH, Dr., habil.
IEE S.A.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG

Office phone :  +352-2454-2566
Office fax:       +352-2454-3566
mobile phone:  +49 151 52 40 66 44

e-mail: alexei.b...@iee.lu

Reply all
Reply to author
Forward
0 new messages