Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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. – Sulli 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

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]},
        PlotRange -> {-\[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


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.