0

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]  
Kuba
  • 136,707
  • 13
  • 279
  • 740
Sulli
  • 2,185
  • 14
  • 28
  • It is the same as here exept that You have DynamicModules not Manipulates. – Kuba Jul 06 '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 06 '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 06 '13 at 10:27

1 Answers1

2

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...:)

cormullion
  • 24,243
  • 4
  • 64
  • 133