Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am new to Mathematica and stuck with one problem i.e.

How can I add a graphics option to an already made plot which 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]

Mathematica graphics

Now I want to add a plot Label by calling the already produced plot s because I don't want the duplication of code again as I have to use 4 more different plots in a popupmenu. For example, when I select s from then 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.

Is there any way to sort out this problem?

Note: The MathGroup version of the same question is found here.

share|improve this question
1  
Welcome to Mathematica.SE! In future question, you can use the formatting controls in the post editor (the {} icon, etc.) to make your post readable. I fixed up the formatting now (you can click the edit link under the post to see how I did it). I also removed the superfluous ] character from the end of the first code block. –  Szabolcs May 28 '12 at 9:32
1  
I can't test now, but would the following work? t = s /. g_Graphics->Show[g, PlotLabel -> "Popup Window Plot"] –  celtschk May 28 '12 at 9:32
    
There is an unnecessary Graphics wrapper in the code. Though it turns out to be very useful in the sense that one does not have to write a replacement (a la @celtschk) that lists all possible plot types. –  István Zachar May 28 '12 at 10:05
    
[When you cross-post to MathGroup, please link the questions/answers together.] (I edited your post to include the link.) (meta.mathematica.stackexchange.com/a/368/12) If you get a good answer there, please come back here and summarize it. –  Szabolcs May 30 '12 at 10:03

2 Answers 2

Maybe as an alternative you could define s as a function, e.g.

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

then for example s[] would give you the original Manipulate and s[PlotLabel -> "Popup Window Plot"] would add a label to the plot inside the Manipulate, etc.

share|improve this answer

Try this:

MapAt[Show[#, PlotLabel -> "Popup Window Plot"] &, s, {1, 1}]

The part specification {1, 1} should point to your Graphics object.

To affect any Graphics in s use as suggested by celtschk:

s /. g_Graphics -> Show[g, PlotLabel -> "Popup Window Plot"]
share|improve this answer
    
I think you need to use SetDelayed in the latter example to replace g, otherwise it drops an error. –  István Zachar May 28 '12 at 10:02
    
thanks it worked... –  Jennifer May 29 '12 at 6:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.