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}]
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?
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]
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.
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"}]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With