Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manipulate : Spacing and Background

Please Consider :

 Manipulate[Rasterize[Graphics[{
    Black, Rectangle[{0, 0}, {6, 10}],
    Red, Rectangle[{0, 0}, {2, L}],
    Green, Rectangle[{2, 0}, {4, M}],
    Blue, Rectangle[{4, 0}, {6, S}]},
    ImageSize -> {200, 270},
    ImageSize -> 50]],
    Control@{{L, 1, Style["L", Red, Bold, 24]}, Range[10], 
    ControlType -> Slider, ControlPlacement -> Top, 
    DefaultBaseStyle -> {Bold, 16, FontFamily -> "Helvetica"}, 
    Appearance -> "Labeled", ImageSize -> 200},
    Control@{{M, 1, Style["M", Green, Bold, 24]}, Range[10], 
    ControlType -> Slider, ControlPlacement -> Top, 
    DefaultBaseStyle -> {Bold, 16, FontFamily -> "Helvetica"}, 
    Appearance -> "Labeled", ImageSize -> 200},
    Control@{{S, 1, Style["S", Blue, Bold, 24]}, Range[10], 
    ControlType -> Slider, ControlPlacement -> Top, 
    DefaultBaseStyle -> {Bold, 16, FontFamily -> "Helvetica"}, 
    Appearance -> "Labeled", ImageSize -> 200}]

enter image description here

  • Can I change the Background Color : Black instead of White for example.

  • Why is there so much empty space on the right. I have never been able to match the slider size with the width of the Manipulate being just enveloping the graphics contained?

like image 334
500 Avatar asked Oct 23 '11 01:10

500


2 Answers

If you set Paneled -> False in Manipulate, it shrinks the white space around the Graphics. The remaining white can be easily set to have a different background by setting it appropriately in the Graphics[...] command. You can also style the outer panel by setting the background in the BaseStyle for Manipulate. Here's a slight modification of your code:

Manipulate[
 Graphics[{Black, Rectangle[{0, 0}, {6, 10}], Red, 
   Rectangle[{0, 0}, {2, L}], Green, Rectangle[{2, 0}, {4, M}], Blue, 
   Rectangle[{4, 0}, {6, S}]}, ImageSize -> {200, 300}, 
  Background -> LightOrange], 
 Control@{{L, 1, Style["L", Red, Bold, 24]}, Range[10], 
   ControlType -> Slider, ImageSize -> Small, ControlPlacement -> Top,
    DefaultBaseStyle -> {Bold, 16, FontFamily -> "Helvetica"}, 
   Appearance -> "Labeled"}, 
 Control@{{M, 1, Style["M", Green, Bold, 24]}, Range[10], 
   ControlType -> Slider, ImageSize -> Small, ControlPlacement -> Top,
    DefaultBaseStyle -> {Bold, 16, FontFamily -> "Helvetica"}, 
   Appearance -> "Labeled"}, 
 Control@{{S, 1, Style["S", Blue, Bold, 24]}, Range[10], 
   ControlType -> Slider, ImageSize -> Small, ControlPlacement -> Top,
    DefaultBaseStyle -> {Bold, 16, FontFamily -> "Helvetica"}, 
   Appearance -> "Labeled"}, BaseStyle -> {Background -> LightPurple},
  Paneled -> False, ImageMargins -> 10]

enter image description here

I hadn't noticed in my previous example that the labels had moved slightly upwards. In any case, belisarius' suggestion of using ImageSize -> Small is simpler, so I've adopted it.

like image 68
abcd Avatar answered Sep 19 '22 14:09

abcd


I think you overused the ImageSize option:

Manipulate[
 Graphics[{Black, Rectangle[{0, 0}, {6, 10}], Red, 
   Rectangle[{0, 0}, {2, L}], Green, Rectangle[{2, 0}, {4, M}], Blue, 
   Rectangle[{4, 0}, {6, S}]}, ImageSize -> {200, 300}],

 Control@{{L, 1, Style["L", Red, Bold, 24]}, Range[10], 
   ControlType -> Slider, ImageSize -> Small, ControlPlacement -> Top,
    DefaultBaseStyle -> {Bold, 16, FontFamily -> "Helvetica"}, 
   Appearance -> "Labeled"}, 
 Control@{{M, 1, Style["M", Green, Bold, 24]}, Range[10], 
   ControlType -> Slider, ImageSize -> Small, ControlPlacement -> Top,
    DefaultBaseStyle -> {Bold, 16, FontFamily -> "Helvetica"}, 
   Appearance -> "Labeled"}, 
 Control@{{S, 1, Style["S", Blue, Bold, 24]}, Range[10], 
   ControlType -> Slider, ImageSize -> Small, ControlPlacement -> Top,
    DefaultBaseStyle -> {Bold, 16, FontFamily -> "Helvetica"}, 
   Appearance -> "Labeled"}]

enter image description here

like image 23
Dr. belisarius Avatar answered Sep 22 '22 14:09

Dr. belisarius