gpt4 book ai didi

wolfram-mathematica - 操纵: Spacing and Background

转载 作者:行者123 更新时间:2023-12-04 08:15:54 30 4
gpt4 key购买 nike

请考虑 :

 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
  • 我可以更改背景颜色吗:例如黑色而不是白色。
  • 为什么右边有这么多空位。我从来没有能够将 slider 大小与 Manipulate 的宽度相匹配,而 Manipulate 只是包围了所包含的图形?
  • 最佳答案

    如果设置 Paneled -> FalseManipulate ,它会缩小 Graphics 周围的空白区域.通过在 Graphics[...] 中适当设置剩余的白色,可以轻松地将其设置为具有不同的背景。命令。您还可以通过在 BaseStyle 中设置背景来设置外部面板的样式。对于 Manipulate .这是对您的代码的轻微修改:

    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

    在我之前的示例中,我没有注意到标签略微向上移动。无论如何,贝利撒留建议使用 ImageSize -> Small更简单,所以我采用了它。

    关于wolfram-mathematica - 操纵: Spacing and Background,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7863680/

    30 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com