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

MathGroup Archive 2012

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

Search the Archive

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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg126668] Re: how to add graphics options in a plot which is already produced and has a manipulator
  • From: "djmpark" <djmpark at comcast.net>
  • Date: Wed, 30 May 2012 04:09:21 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <8042653.8084.1338285425344.JavaMail.root@m06>

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
djmpark at comcast.net 
http://home.comcast.net/~djmpark/index.html 


From: Jennifer [mailto:ptewari786 at gmail.com] 

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"




  • Prev by Date: Re: Stop on message?
  • Next by Date: Re: Sum of Products
  • Previous by thread: how to add graphics options in a plot which is already produced and has a manipulator
  • Next by thread: Re: how to add graphics options in a plot which is already produced and has a manipulator