Overlay
Details and Options
- The expri can be graphics, text, or any other expressions.
- In Overlay[{expr1,expr2,…}] the later expri are rendered on top of earlier ones.
- Overlay[exprs] is equivalent to Overlay[exprs,All,None] and displays as an overlay of all the exprs.
- Overlay[exprs] by default allows no selection within the exprs.
- The following options can be given:
-
Alignment {Automatic,Automatic} how to align objects in the display area Background None background color to use BaselinePosition Automatic what to align with a surrounding text baseline BaseStyle {} base style specifications for the displayed object ContentPadding True whether to shrink the margins tightly around the contents FrameMargins Automatic margins to leave inside the overall frame ImageMargins 0 margins around the image of the displayed object ImageSize Automatic the overall image size for the displayed object - With the default option setting ImageSize->Automatic, Overlay leaves space only for the expri currently being displayed.
- With the option setting ImageSize->All, Overlay always leaves space for the largest of the expri to be displayed, so that its overall size does not change.
- The settings for BaseStyle are appended to the default style given by the "Overlay" style in the current stylesheet.
Examples
open all close allBasic Examples (2)
Scope (5)
Style[Overlay[Range[9]], 48]Overlay two-dimensional and three-dimensional graphics:
Overlay[{Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3}], Plot[Sin[x], {x, 0, 6}]}]Overlay[{StringTake[ExampleData[{"Text", "ToBeOrNotToBe"}], 400], Plot[Sin[E ^ x], {x, 0, 5}]}]Overlay[{Button["short"], Button[" long"], Button[" medium"]}, {2, 3, 1}]Allow clicks in the back layer:
Overlay[{Slider2D[], Graphics[{Opacity[.2], Disk[]}]}, All, 1]Generalizations & Extensions (1)
Overlay with a single element is similar in behavior to a PaneSelector:
Grid[{{SetterBar[Dynamic[x], {1, 2, 3}], Overlay[{"aaa", "bbb", "ccc"}, Dynamic[{x}]], PaneSelector[{1 -> "aaa", 2 -> "bbb", 3 -> "ccc"}, Dynamic[x]]}}, Frame -> All]Options (5)
Alignment (1)
Background (1)
BaseStyle (1)
Set the base style of an Overlay:
Overlay[{1, 2, 3}, BaseStyle -> {FontSize -> 24}]ImageSize (2)
By default, Overlay allocates room for all visible objects:
Framed[Overlay[{1, 22, 3333333}, {1, 2}]]Allocate room for all objects regardless of visibility:
Framed[Overlay[{1, 22, 3333333}, {1, 2}, ImageSize -> All]]Set the overlay to a specific size in points:
Framed[Overlay[{1, 22, 3333333}, ImageSize -> {100, 50}]]Applications (3)
Make a new character from existing characters:
Overlay[{"⥟", "⥗"}]Overlay[{Manipulate[x, {x, 0, 1}], Graphics[Text[Style["Confidential", Bold, Red, Opacity[.1], 40], {0, 0}, {0, 0}, {1, .3}], ImageSize -> {250, 100}]}]Create an image map using invisible controls overlaid onto an image:
calcButtonFactory[row_, col_] := With[{val = Switch[{row, col}, {1, 3}, ".", {1, _}, 0, _, (row - 2) * 3 + col]}, Tooltip[Button["", Print[val], Appearance -> None, ImageSize -> {70, 70}], val]];The controls create a photorealistic, fully functional numeric keypad:
Overlay[{Show[[image]], Grid[Table[calcButtonFactory[row, col], {row, 4, 1, -1}, {col, 1, 3}], Spacings -> {0, 0}, ItemSize -> All]}, All, 2]Possible Issues (2)
Expressions in front may completely obscure expressions behind them:
Overlay[{ExampleData[{"TestImage", "Clock"}], Plot[Cos[x], {x, 0, 6}, Background -> Orange]}, Alignment -> Center]Using transparency or removing background colors might achieve the desired appearance:
Overlay[{ExampleData[{"TestImage", "Clock"}], Plot[Cos[x], {x, 0, 6}, Background -> Directive[{Opacity[0.5], Orange}]]}, Alignment -> Center]Overlay prevents tooltips not in the active layer from firing:
Overlay[{Tooltip[Framed["hidden tooltip"], "hidden"], Plot[x, {x, 0, 1}]}, Alignment -> Center]Use the third argument to specify the layer where tooltips should be active:
Overlay[{Tooltip[Framed["visible tooltip"], "visible"], Plot[x, {x, 0, 1}]}, All, 1, Alignment -> Center]Neat Examples (2)
Use Overlay to make a fading transition effect:
Manipulate[Overlay[{ExampleData[{"TestImage", "House"}], SetAlphaChannel[ExampleData[{"TestImage", "Clock"}], x]}], {x, 0, 1}]
| |
| |
| |
Create a decorative frame for a 3D object which can still be rotated:
mask = Blur[Image[Graphics[Disk[{0, 0}, .7], PlotRange -> {-1, 1}, ImageSize -> {144, 144}]], 30]Overlay[{Graphics3D[{Cone[]}, ImageSize -> {144, 144}, Boxed -> False], SetAlphaChannel[Image[Graphics[{}, ImageSize -> {144, 144}, Background -> Brown]], mask]}, All, 1]Related Guides
Related Workflows
- Combine Multiple Images ▪
- Combine Graphics
History
Text
Wolfram Research (2010), Overlay, Wolfram Language function, https://reference.wolfram.com/language/ref/Overlay.html.
CMS
Wolfram Language. 2010. "Overlay." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Overlay.html.
APA
Wolfram Language. (2010). Overlay. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Overlay.html
BibTeX
@misc{reference.wolfram_2026_overlay, author="Wolfram Research", title="{Overlay}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/Overlay.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_overlay, organization={Wolfram Research}, title={Overlay}, year={2010}, url={https://reference.wolfram.com/language/ref/Overlay.html}, note=[Accessed: 13-June-2026]}