7
$\begingroup$

Please consider the following:

 Manipulate[Plot[Sin[x (1 + a x)], {x, 0, 6}], {a, 0, 2}];

Now, I would like to change the background colour to yellow. I tried the following, but in this case the nice looking rounded corners of the manipulate element get lost:

Panel[#, Background -> Yellow] &@
 Manipulate[Plot[Sin[x (1 + a x)], {x, 0, 6}], {a, 0, 2}, 
  Paneled -> False]

Maybe somebody has a better idea.

EDIT

The background colour of Manipulateis by default grey. <code>Manipulate</code>

In addition the graphical element in which the Manipulate is embedded has rounded corners rounded corner which I would like to keep. Applying my approach will change the colour but I loose the rounded corners.

$\endgroup$
3
  • $\begingroup$ What rounded corners? Please include an image of your desired result $\endgroup$ Aug 24, 2012 at 14:34
  • 1
    $\begingroup$ Panel[] (and thus Manupulate[] too) in Windows 7 does not have round corners. It is kind of system dependent. $\endgroup$ Aug 24, 2012 at 17:31
  • $\begingroup$ @NasserM.Abbasi Good advice, because I intend to deploy my notebook as a CDF. Would the wrapper cause problems then? If so, I may post a new thread on this issue. $\endgroup$
    – John
    Aug 24, 2012 at 23:50

3 Answers 3

12
$\begingroup$

If you would like to change background of Manipulate function - this is a way. Note I'll show you most difficult case when you have to go from light to dark colors change - then you have to pay attention to styling of internal graphics too, so everything (like ticks) are visible.

st = {FontColor -> GrayLevel[.7]};
Framed[Manipulate[
  Plot[Sin[x (1 + a x)], {x, 0, 6}, Background -> GrayLevel[.3], 
   PlotStyle -> {Thick, Orange}, Frame -> True, BaseStyle -> st, 
   ImageMargins -> 7], {{a, 1, "frequency"}, 0, 2, 
   Appearance -> "Labeled"}, Paneled -> False], FrameMargins -> 30, 
 Background -> Black, BaseStyle -> st, RoundingRadius -> 10]

enter image description here

$\endgroup$
4
  • $\begingroup$ Nice... can't say I agree with your dark color scheme though... $\endgroup$
    – kale
    Aug 24, 2012 at 14:48
  • $\begingroup$ @VitaliyKaurov Good one! In my case I think I can delete the BaseStyle-Options within the Framed-environment. Otherwise somehow the corners look very pixeled. $\endgroup$
    – John
    Aug 24, 2012 at 14:56
  • $\begingroup$ @John Thanks! Sure, I was just trying to show full scope. Maybe reducing RoundingRadius can also help. BTW if you accepted it, you could probably up vote it too? ;-) $\endgroup$ Aug 24, 2012 at 14:58
  • $\begingroup$ @VitalyKaurov I'm sorry. I didn't pay attention for a sec. $\endgroup$
    – John
    Aug 24, 2012 at 15:18
7
$\begingroup$

Wrapping Manipulate in Style and using DefaultOptions to set background color of Panel and then adjusting FrameMargins manually:

Panel[Style[Manipulate[
Plot[Sin[x (1 + a x)], {x, 0, 6}, Background -> None], {a, 0, 2}], 
DefaultOptions -> {Panel -> {Background -> LightBlue}}], 
FrameMargins -> {{-3, -2}, {-2, -3}}]

you get

enter image description here

Panel[Style[Manipulate[
Plot[Sin[x (1 + a x)], {x, 0, 6}, Background -> LightBlue], {a, 0, 2}, 
FrameMargins -> {{-4, -3}, {-2, -2}}], 
DefaultOptions -> {Panel -> {Background -> LightBlue}}], 
      FrameMargins -> {{-3, -2}, {-2, -3}}]

gives

enter image description here

Update: Screenshot of free-cdf version deployed as stand-alone and viewed in browser window:

enter image description here

$\endgroup$
4
  • $\begingroup$ uh, this is really hard on the eyes! $\endgroup$
    – Yves Klett
    Aug 24, 2012 at 16:22
  • 1
    $\begingroup$ @YvesKlett, hope LightBlue is better :) $\endgroup$
    – kglr
    Aug 24, 2012 at 17:50
  • $\begingroup$ @kguler please check Nasser M. Abassis' comment on wrappers around Manipulate and demos. $\endgroup$
    – John
    Aug 24, 2012 at 23:52
  • 1
    $\begingroup$ @John, I am not sure, but I think Nasser's comment refers to the requirements for demonstrations for deploying in Wolfram Demonstrations site. I was able to use the code in a new cdf document, deploy it as stand-alone and view it in IE browser without any problem. I posted the screenshot. $\endgroup$
    – kglr
    Aug 25, 2012 at 0:34
1
$\begingroup$

Not sure if you can do it in a Manipulate wrapper, but you could technically build your own as such:

Panel[Column[{Manipulator[Dynamic[a], {0, 10}], 
   Dynamic[Plot[Sin[x (1 + a x)], {x, 0, 6}]]}], 
 Background -> LightGreen]

enter image description here

Or...

Panel[Column[{Manipulator[Dynamic[a], {0, 10}], 
   Panel[Dynamic[Plot[Sin[x (1 + a x)], {x, 0, 6}]], 
    Background -> LightGreen]}]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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