Can I apply Style to the output of "Labeled" in the below ?
Manipulate[\[Lambda],
Control#{{\[Lambda], 401,
Style[" \[Lambda]", Black, Bold, 24]},
Range[401, 570, 1],
ControlType -> Slider,
ControlPlacement -> Bottom,
Appearance -> "Labeled",
ImageSize -> 200}]
That is on the right part of the Slider :
You want the option BaseStyle (which appears in Options[Slider]). E.g.
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"}}]
When looking at this I noticed that you can also use the almost undocumented ControlType -> LabeledSlider, just for something different.
It seems to be at least partially affected by LabelStyle and BaseStyle. (I'm having trouble changing the font, for some reason, but size, weight, color seem to work fine.)
Related
I wonder if it is possible to make a variable that holds info obout wanted style for Show[] function. So ewery time i want to display plots in Show[] i will insert that variable in Show[] to set options for style.
I want something like this...
OPTIONS=
AxesOrigin -> Automatic,
LabelStyle -> Directive[14, Black, Bold, Italic],
ImageSize -> {450}
Show[
ListLinePlot[data],
OPTIONS
]
The solution is simple but im green. :)
OPTIONS = {AxesOrigin -> Automatic,
LabelStyle -> Directive[14, Red, Bold, Italic], ImageSize -> {450}}
Show[ListLinePlot[{1, 2, 3, 4, 5}], OPTIONS]
Works for me.
You could apply Show with options to graphics automatically using $Post, e.g.
$Post := With[{opts = {
AxesOrigin -> Automatic,
LabelStyle -> Directive[14, Black, Bold, Italic],
ImageSize -> {250}}},
If[Head[#] === Graphics, Show[#, opts], #] &]
ListLinePlot[{1, 2, 3, 4, 5}]
Restoring $Post to default:
$Post =.
This is an example of what I'd like to do: Do all the display in the control area of Manipulate itself:
Manipulate[
p = Framed#
Plot[Sin[x],{x, -y, y},ImageSize->300,Background-> White, ImagePadding -> 20];
{},
Grid[{
{Control[{{y, N#Pi/2, "y"}, -Pi, Pi, Appearance -> "Labeled"}]},
{Dynamic#p}
}],
ControlPlacement -> Left,
Alignment -> Center,
ImageMargins -> 1,
FrameMargins -> 1,
ContentSize -> {0}
]
The problem is that M adds a scroll bar automatically:
The help says
If ContentSize specifies a content area that does not completely fit
the contents, then unless specified otherwise with AppearanceElements,
functions like Manipulate display a resize area, as well as scrollbars
when necessary.
The question is, how to use AppearanceElements to remove this scrollbar?
(I wish sometimes that M help is not so short and brief when explaining something).
In the above, notice it says: unless specified otherwise with AppearanceElements,
but I was not able to find out what this means. What does 'otherwise' is
supposed to mean?
The closest I got is by adding AppearanceElements -> "" to the above. So the new
version now becomes
Manipulate[
p = Framed#
Plot[Sin[x], {x, -y, y}, ImageSize -> 300, Background -> White,
ImagePadding -> 20];
{},
Grid[{
{Control[{{y, N#Pi/2, "y"}, -Pi, Pi, Appearance -> "Labeled"}]},
{Dynamic#p}
}],
ControlPlacement -> Left,
Alignment -> Center,
ImageMargins -> 1,
FrameMargins -> 1,
ContentSize -> {0},
AppearanceElements -> "" (*added this *)
]
But notice that the size is not quite correct to the right still, it should be more tight,
and I also lost the '+' that used to be there. I have to keep that.
So, I think what I need is just to find what the element name for '+' is, so I can use
the correct AppearanceElements -> "correctNameHere" and I am hoping that this
will do the right thing. (I tried "Close" but that did not do it, I lost the '+' as well)
I just could not find what that '+' element name is. Any one knows?
Here are the places to find more information on this:
http://reference.wolfram.com/mathematica/ref/Manipulator.html
http://reference.wolfram.com/mathematica/ref/ContentSize.html
So, the question is: How to completely remove the scrollbar effect shown
above, but at the same time keep the '+' in the top right corner.
thanks
Update 2
Thanks to the answers below, here is a screen shot of the result.
Manipulate[
p = Framed#
Plot[Sin[x], {x, -y, y}, ImageSize -> 300, Background -> White,
ImagePadding -> 20];
{}, Grid[{{Control[{{y, N#Pi/2, "y"}, -Pi, Pi,
Appearance -> "Labeled"}]}, {Dynamic#p}}],
AppearanceElements -> "BookmarksButton", ControlPlacement -> Left,
Alignment -> Center, ImageMargins -> 1, FrameMargins -> 1,
ContentSize -> {0}, Alignment -> Center]
I am happy with it. The small white line showing at the top corner seems to
be a side-effect of this. Will have to live it I guess.
Manipulate[
p = Framed#
Plot[Sin[x], {x, -y, y}, ImageSize -> 300, Background -> White,
ImagePadding -> 20];
{}, Grid[{{Control[{{y, N#Pi/2, "y"}, -Pi, Pi,
Appearance -> "Labeled"}]}, {Dynamic#p}}]
, AppearanceElements -> "ManipulateMenu", ControlPlacement -> Left,
Alignment -> Center, ImageMargins -> 1, FrameMargins -> 0,
ContentSize -> {0} ]
Setting FrameMargins->0 gets rid of white lines (on a Mac anyway) but still leaves the Frame lines there. Frame->False doesn't change this. It appears that Manipulate wants to draw a content area no matter what. The AppearanceElements option seems to be incompletely/poorly documented. The following are valid options, though there may be others I do not know of:
{"ContentResizeArea", "HideControlsButton", "ManipulateMenu", "SnapshotButton",
"ResetButton", "UpdateButton", "BookmarksButton", All, None}
AppearanceElements -> "BookmarksButton" is what you are looking for. Other AppearanceElementsfor Manipulate in the documentation (ref/Manipulate) are {"HideControlsButton", "SnapshotButton", "ResetButton",
"UpdateButton", All}
Adding Paneled->False as an option to Manipulate gets rid of the white frame. By wrapping Manipulate with Panel you get something that looks like what you need:
Manipulate[ p = Framed#Plot[Sin[x], {x, -y, y}, ImageSize -> 300,
Background -> White, ImagePadding -> 20]; {},
Grid[{{Control[{{y, N#Pi/2, "y"}, -Pi, Pi,
Appearance -> "Labeled"}]}, {Dynamic#p}}],
AppearanceElements -> "BookmarksButton", ControlPlacement -> Left,
Alignment -> Center, ImageMargins -> 1, FrameMargins -> 0,
ContentSize -> {0}, Paneled->False ]//Panel
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"}]
Considering the following BarChart :
How Could I adjust the Font for the Labeling Function as well as the Chart Labels ?
I tried nesting Style. Unsuccessfull.
BarChart[{1, 2, 3, 4},
ChartStyle -> {Blue, Red, Green, Yellow},
LabelStyle -> Directive[Black, Large],
ChartLabels -> {"COG1", "COG2", "COG3", "COG4"},
ImageSize -> {500, 300},
ChartBaseStyle -> EdgeForm[Thick],
LabelingFunction -> Bottom,
Background -> Black,
LabelStyle -> Directive[Black, Large]]
Do you mean something like this?
BarChart[{1, 2, 3, 4},
ChartStyle -> {Blue, Red, Green, Yellow},
ChartLabels -> (Style[#, Large, White] & /# {"COG1", "COG2", "COG3", "COG4"}),
LabelingFunction -> (Placed[Style[#, Large], Bottom] &),
ImageSize -> {500, 300},
ChartBaseStyle -> EdgeForm[Thick],
Background -> Black,
AxesStyle -> White, LabelStyle -> {Large}]
Edit
Change the style of the axes.
How do you set up manipulate so that you can control a variable with a vertical slider instead of a horizontal slider in Mathematica?
From the help ....
Manipulate[u, {u, 0, 1, ImageSize -> Small},
ControlType -> VerticalSlider, ControlPlacement -> Left]