2011-10-23 3 views
5

가 고려하십시오 :는 조작 : 간격과 배경

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]], 
    [email protected]{{L, 1, Style["L", Red, Bold, 24]}, Range[10], 
    ControlType -> Slider, ControlPlacement -> Top, 
    DefaultBaseStyle -> {Bold, 16, FontFamily -> "Helvetica"}, 
    Appearance -> "Labeled", ImageSize -> 200}, 
    [email protected]{{M, 1, Style["M", Green, Bold, 24]}, Range[10], 
    ControlType -> Slider, ControlPlacement -> Top, 
    DefaultBaseStyle -> {Bold, 16, FontFamily -> "Helvetica"}, 
    Appearance -> "Labeled", ImageSize -> 200}, 
    [email protected]{{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

  • 가 나는 배경 색상을 변경할 수 있습니다 : 검은 색 대신 흰색의 예를 들어.

  • 왜 오른쪽에 너무 많은 빈 공간이 있습니다. 나는 슬라이더 크기를 Manipulate의 너비와 일치시킬 수 없었습니다.

+0

음 ... 회색 부분은 조절할 수 있지만 흰색은 조절할 수 없습니다. – abcd

+0

@Yoda, 나는 관심이있다! 어떻게? 그리고 오른쪽에있는 피상적 인 공간을 위해 무엇이든 할 수 있습니까? – 500

답변

5

당신이 Manipulate에서 Paneled -> False, 그것은이 Graphics 주위의 공백을 축소 설정합니다. 나머지 흰색은 Graphics[...] 명령에서 적절하게 설정하여 다른 배경을 갖도록 쉽게 설정할 수 있습니다. 에 대해 BaseStyle의 배경을 설정하여 외부 패널의 스타일을 지정할 수도 있습니다. 여기에 코드를 약간 수정이다 : 나는 내 앞의 예에서 발견하지 않았다

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], 
[email protected]{{L, 1, Style["L", Red, Bold, 24]}, Range[10], 
    ControlType -> Slider, ImageSize -> Small, ControlPlacement -> Top, 
    DefaultBaseStyle -> {Bold, 16, FontFamily -> "Helvetica"}, 
    Appearance -> "Labeled"}, 
[email protected]{{M, 1, Style["M", Green, Bold, 24]}, Range[10], 
    ControlType -> Slider, ImageSize -> Small, ControlPlacement -> Top, 
    DefaultBaseStyle -> {Bold, 16, FontFamily -> "Helvetica"}, 
    Appearance -> "Labeled"}, 
[email protected]{{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

라벨이 약간 위쪽으로 이동했다고. 어쨌든,을 사용하는 belisarius의 제안은 더 간단합니다. 그래서 그것을 채택했습니다.

+0

그래서 더 많은 퇴비를 수직으로 만들기 위해 측면에 라벨을 붙일 방법이 없습니까? 이미 굉장합니다 ... – 500

+0

'BaseStyle' 옵션이 내 시스템에서 작동하지 않습니다 (Windows XP 32 비트에서 MMa 8.0.1). –

+0

@ 500 나는 다른 색깔에 백색을 변화시키는 방법을 계산했다. 내 편집을 참조하십시오. belisarius의 코드에서와 같이'ImageSize -> Small'을 사용하는 것이'LabeledSlider'를 사용하여 레이블을 올리는 것과 씨름하는 것보다 간단하다고 생각합니다. – abcd

3

나는 당신이 ImageSize 옵션을 남용 생각 :

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}], 

[email protected]{{L, 1, Style["L", Red, Bold, 24]}, Range[10], 
    ControlType -> Slider, ImageSize -> Small, ControlPlacement -> Top, 
    DefaultBaseStyle -> {Bold, 16, FontFamily -> "Helvetica"}, 
    Appearance -> "Labeled"}, 
[email protected]{{M, 1, Style["M", Green, Bold, 24]}, Range[10], 
    ControlType -> Slider, ImageSize -> Small, ControlPlacement -> Top, 
    DefaultBaseStyle -> {Bold, 16, FontFamily -> "Helvetica"}, 
    Appearance -> "Labeled"}, 
[email protected]{{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

+0

고맙습니다 슬라이더 높이를 계속 유지할 때까지 슬라이더를 끝까지 유지할 ​​수 있기를 바랍니다. – 500

+0

@ 500 문제는 "레이블이 붙어있는"것이 보이는 숫자에서 큰 여백을 오른쪽 여백까지두고 문제가되는 것입니다. 크기를 조정할 방법이 없습니다. –

관련 문제