Take the 2-minute tour ×

I am generating a graph through a custom function using DynamicModule:

graph1 = customFunction[a]

If I try to do:


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]  
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
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

1 Answer 1

Following up Kuba's comment:

  DynamicModule[{a}, Row[
     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]]
     Slider[Dynamic[b], {-5, 5}, Appearance -> "Labeled"],
     Dynamic[plot2 = Plot[Tan[b x], {x, -\[Pi], \[Pi]},
        Background -> LightGreen,
        AspectRatio -> 1,
        ImageSize -> 250]]
   }, " "


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


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

Your Answer


