2011-10-16 81 views
7

我可以将Style应用于下面的“Labeled”输出吗?风格动态值

Manipulate[\[Lambda], 
[email protected]{{\[Lambda], 401, 
Style["  \[Lambda]", Black, Bold, 24]}, 
Range[401, 570, 1], 
ControlType -> Slider, 
ControlPlacement -> Bottom, 
Appearance -> "Labeled", 
ImageSize -> 200}] 

也就是说在滑块的右侧部分:

enter image description here

+3

你可以使用'ControlType-> LabeledSlider'并放置'Appearance - >“Labeled”''部件。这会给你一个更紧凑和整洁的盒子。 – abcd

+0

但是然后数字在我的底下。 – 500

+0

@ 500:如果您为'Manipulate'设置'ControlPlacement - > Bottom'而不是单个控制器,那么它不影响标签在'LabeledSlider'中的位置。 – Simon

回答

10

您需要选项BaseStyle(它出现在Options[Slider]中)。例如。

Manipulate[ 
Plot[Cos[k x], {x, 0, 2 Pi}, PlotLabel -> "Cosine"], 
{{k, 1, Style["x", Black, Bold, 24]}, 0, 4, 
    ControlType -> Slider, Appearance -> "Labeled", 
    ControlPlacement -> Bottom, ImageSize -> 200, 
    BaseStyle -> {Red, Large, Italic, FontFamily -> "Times"}}] 

cosine

当这个样子,我注意到,你也可以使用almost undocumentedControlType -> LabeledSlider,只是不同的东西。

+0

现在我注意到yoda刚刚评论过上面的'LabeledSlider' ... – Simon

+0

谢谢Simon,但它干扰了我的情节标签。有没有一种方法可以避免这种情况? – 500

+0

@ 500:必须为控制对象设置'DefaultBaseStyle' - 而不是操纵。查看编辑。 – Simon

2

这似乎是至少部分地受LabelStyleBaseStyle。 (由于某些原因,我在更改字体时遇到了问题,但尺寸,重量和颜色似乎正常工作。)