Tell me more ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
What rounded corners? Please include an image of your desired result – belisarius Aug 24 '12 at 14:34
1  
Panel[] (and thus Manupulate[] too) in Windows 7 does not have round corners. It is kind of system dependent. – Yu-Sung Chang Aug 24 '12 at 17:31
Just a note: For demonstrations project, the Manipulate must be the first construct used. No wrapper allowed around it. (just in case someone wants to use some of these nice solutions for a demo, just be aware of this). – Nasser Aug 24 '12 at 17:57
@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. – John Aug 24 '12 at 23:50
@John, the restriction for having Manipulate be the first thing is only for making CDF that you are planning to submit for publication at the WRI demo site. Otherwise, you are free to wrap the Manipulate with Panel or other things. It should not be a problem. This restriction is just one of the rules for CDF meant to be put on the WRI demo site that is all. – Nasser Aug 25 '12 at 0:17

3 Answers

up vote 8 down vote accepted

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

share|improve this answer
Nice... can't say I agree with your dark color scheme though... – kale Aug 24 '12 at 14:48
@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. – John Aug 24 '12 at 14:56
@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? ;-) – Vitaliy Kaurov Aug 24 '12 at 14:58
@VitalyKaurov I'm sorry. I didn't pay attention for a sec. – John Aug 24 '12 at 15:18

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

share|improve this answer
uh, this is really hard on the eyes! – Yves Klett Aug 24 '12 at 16:22
1  
@YvesKlett, hope LightBlue is better :) – kguler Aug 24 '12 at 17:50
@kguler please check Nasser M. Abassis' comment on wrappers around Manipulate and demos. – John Aug 24 '12 at 23:52
1  
@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. – kguler Aug 25 '12 at 0:34

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

share|improve this answer

Your Answer

 
discard

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.