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 generating a graph through a custom function using DynamicModule:

graph1 = customFunction[a]

If I try to do:

Show[graph1]

I get the message

"DynamicModule is not a type of graphics."

How can I convert the output of my DynamicModule function into a graphic? My ultimate goal is to combine multiple graphics with Show:

graph1 = customFunction[a]
graph2 = customFunction[b]  
Show[graph1,graph2]  
share|improve this question
    
It is the same as here exept that You have DynamicModules not Manipulates. –  Kuba Jul 6 '13 at 10:01
    
OK thanks so what it means is that I have to pass the name of the graph I want to plot to my customFunction and then plot the graph inside this variable. –  su1 Jul 6 '13 at 10:22
1  
No, You only have to assign graphics object inside Your DynamicModule to variable, and then Show it outsiede, like in the link. Well, I can not guess more without any insight into Your code. –  Kuba Jul 6 '13 at 10:27
add comment

1 Answer

Following up Kuba's comment:

  DynamicModule[{a}, Row[
  {
   Column[
    {
     Slider[Dynamic[a], {0, 5}, Appearance -> "Labeled"],
     Dynamic[plot1 = Plot[Sin[a x], {x, -\[Pi], \[Pi]},
        PlotRange -> {-\[Pi], \[Pi]},
        Background -> LightBlue,
        AspectRatio -> 1,
        ImageSize -> 250]]
     }],
   Column[
    {
     Slider[Dynamic[b], {-5, 5}, Appearance -> "Labeled"],
     Dynamic[plot2 = Plot[Tan[b x], {x, -\[Pi], \[Pi]},
        PlotRange -> {-\[Pi], \[Pi]},
        Background -> LightGreen,
        AspectRatio -> 1,
        ImageSize -> 250]]
     }]
   }, " "
  ]]

plots

Show[plot1, plot2, Background -> LightPurple] // Dynamic

combined

The bottom graphic updates as you adjust the sliders. I had to mix the Blue and Green backgrounds manually, of course...:)

share|improve this answer
add comment

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.