1
$\begingroup$

I'm not sure what the issue is here. Part of the Plot3D graph disappears when I use the slider.

Manipulate[
 Show[{
   Plot3D[x^2 + 2 y^2, {x, y} \[Element] Disk[]],
   Graphics3D[{Black, Thick, 
     Line[{{Cos[t], Sin[t], 0}, {Cos[t], Sin[t], 
        Cos[t]^2 + 2 Sin[t]^2}}]}]}, PlotRange -> 2],
 {t, 0, 2 Pi}]

How can I fix this? I run across these issues from time to time when using multiple graphics with Manipulate. Either it runs too slow or get some kind of behavior shown here. Can you direct to some tips on programming Manipulates?

enter image description here

$\endgroup$
9
  • $\begingroup$ Since you're not actually Manipulateing the plot, you should generate the Plot3D outside of the Manipulate and insert it with With. That will fix this issue and possibly others. $\endgroup$
    – b3m2a1
    Dec 26, 2017 at 4:52
  • $\begingroup$ Wow! That did it. This will definitely fix a number my issues. $\endgroup$
    – B flat
    Dec 26, 2017 at 4:58
  • 1
    $\begingroup$ add the option PerformanceGoal -> "Quality" to Plot3D? $\endgroup$
    – kglr
    Dec 26, 2017 at 5:00
  • $\begingroup$ Someone just posted an alternate answer that I thought worked well. Any chance you could put it back up? $\endgroup$
    – B flat
    Dec 26, 2017 at 5:09
  • 1
    $\begingroup$ @MichaelMcCain I removed my answer since I saw your answer after posting. They are the same thing. I like put stuff inside Initialization that is all. When Making demos for Wolfram website, all things like this has to go to Initialization. So I am used to doing it that way. $\endgroup$
    – Nasser
    Dec 26, 2017 at 5:25

1 Answer 1

3
$\begingroup$

Thanks to b3m2a1,

With[{sd = Plot3D[x^2 + 2 y^2, {x, y} \[Element] Disk[]]}, 
 Manipulate[

  Show[{
    sd,

    Graphics3D[{Black, Thick, 
      Line[{{Cos[t], Sin[t], 0}, {Cos[t], Sin[t], 
         Cos[t]^2 + 2 Sin[t]^2}}]}]}, PlotRange -> 2],

  {t, 0, 2 Pi}]]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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