Opacity
Details
- Opacity runs from 0 to 1, with 0 representing perfect transparency.
- If an opacity-a object with color c1 is placed in front of an object with color c2, the resulting color will be the blend ac1+(1-a)c2.
- If red and blue with opacity 0.5 are combined, the result is purple—not black, as it would be with physical monochromatic filters. »
- Opacity works in both 2D and 3D graphics.
- It may take significantly longer to render 3D graphics that involve transparent surfaces.
- Graphics that involve transparency may need to be printed as high‐resolution bitmaps.
- On many computer systems, objects with opacity a will appear completely transparent if a is too small. »
Examples
open all close allBasic Examples (3)
Make a 50% transparent sphere:
Graphics3D[{Opacity[0.5], Sphere[]}]Plot3D[Sin[x + y ^ 2], {x, -3, 3}, {y, -2, 2}, PlotStyle -> Opacity[0.5]]Overlapping translucent 2D disks:
Graphics[{Opacity[0.5], Red, Disk[], Green, Disk[{1, 0}]}]Scope (3)
Larger opacity makes surfaces more opaque:
Table[Graphics3D[{Opacity[a], Sphere[]}], {a, 0, 1, 1 / 3}]Opacity is kept throughout the scope of graphics directives:
Graphics3D[{Opacity[.5], Red, Sphere[], Green, Sphere[{3 / 2, 0, 0}], Blue, Sphere[{5 / 2, 0, 0}]}]Color primitives can be used with Opacity:
Table[Graphics3D[{Opacity[a, Hue[2 / 3]], Sphere[]}], {a, 0, 1, 1 / 3}]Generalizations & Extensions (1)
Directive can be used to combine colors with opacity:
Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3}, PlotStyle -> Directive[Opacity[.5], Blue]]Applications (3)
Plot3D[Sin[x ^ 2 + y ^ 2], {x, -3, 3}, {y, -3, 3}, ColorFunction -> (Directive[Opacity[#], Blue]&), PlotPoints -> 40, Mesh -> None]Use Opacity to understand complicated surfaces:
ParametricPlot3D[ {Cos[u], Sin[u] + Cos[v], Sin[v]}, {u, 0, 2π}, {v, -π, π}, PlotStyle -> Directive[Opacity[0.7], Yellow, Specularity[White, 50]], Mesh -> None]Plot3D[Im[ Sec[(x + I y) ^ 3]], {x, -2, 2}, {y, -2, 2}, PlotPoints -> 40, PlotStyle -> Directive[ Opacity[0.9], Yellow, Specularity[White, 50]], Mesh -> None, ClippingStyle -> Opacity[0.3]]Use Opacity to visualize internal structure, in this case two ellipsoidal shells:
ContourPlot3D[4x ^ 2 + y ^ 2 + z ^ 2, {x, -4, 4}, {y, -4, 4}, {z, -4, 4}, Contours -> {4, 16}, ContourStyle -> Opacity[0.8], Mesh -> None]Properties & Relations (7)
Overlapping of translucent red and blue disks results in purple:
Graphics[{Opacity[0.5, Red], Disk[], Opacity[0.5, Blue], Disk[{1, 0}]}]Background color can be seen through a transparent object:
{Graphics[{Opacity[0.5], Red, Disk[]}],
Graphics[{Opacity[0.5], Red, Disk[]}, Background -> Yellow]}Opacity plus color can also be specified using the optional final parameter of various color directives:
Graphics[{{GrayLevel[0], Disk[{0, 0}]}, {GrayLevel[0, 0.3], Disk[{1, 0}]}}]Graphics[{{RGBColor[1, 0, 0], Disk[{0, 0}]}, {RGBColor[0, 1, 0, 0.3], Disk[{1, 0}]}}]Each color primitive supports an extended form that can be used to specify opacity:
{Graphics3D[{Opacity[.5], RGBColor[1, 0, 0], Sphere[]}], Graphics3D[{RGBColor[1, 0, 0, .5], Sphere[]}]}{Graphics3D[{Opacity[.5], Hue[1 / 4, 1, 1], Sphere[]}], Graphics3D[{Hue[1 / 4, 1, 1, .5], Sphere[]}]}{Graphics3D[{Opacity[.5], CMYKColor[1, 0, 0, 0], Sphere[]}], Graphics3D[{CMYKColor[1, 0, 0, 0, .5], Sphere[]}]}Opacity is used by default to show overlapping fillings:
Plot[{Sin[x], Cos[x]}, {x, 0, 3Pi}, Filling -> Axis]Opacity is used for fillings to surface plots:
Plot3D[Sin[x + y ^ 2], {x, -2, 2}, {y, -2, 2}, Filling -> Bottom, RegionFunction -> (#1 ^ 2 + #2 ^ 2 < 3&)]Opacity is used in ParametricPlot to visualize regions that get covered multiple times:
ParametricPlot[Evaluate@RotationTransform[θ][{2Cos[u], Sin[u]}], {u, 0, 2Pi}, {θ, 0, Pi / 2}]Possible Issues (5)
If the opacity is too small, objects will typically render as completely transparent:
Graphics[{Opacity[1 / 1000], Disk[]}]Overlapping of multiple translucent objects can generate an opaque result:
Graphics[{Opacity[1 / 5], Table[Disk[{i / 10, 0}], {i, 10}]}]If each opacity is too small, any number of elements together will still render as transparent:
Graphics[{Opacity[1 / 100], Table[Disk[{i / 10, 0}], {i, 10}]}]Completely transparent objects are still counted for PlotRange:
{Graphics[{Disk[], Disk[{0, 1}]}, Frame -> True], Graphics[{Disk[], Opacity[0], Disk[{0, 1}]}, Frame -> True]}The two-argument form of Opacity might be partially modified by subsequent directives:
Graphics[{Opacity[0.3, Orange], Blue, Disk[]}]Graphics[{Opacity[0.3, Orange], Opacity[1], Disk[]}]The default rendering of opacity may clip objects that are behind too many other objects in 3D graphics:
g = Graphics3D[{Thickness[.05], Line[{{-1, -1, 0}, {1, 1, 0}}], Opacity[.1], Table[Sphere[{0, 0, 0}, i], {i, .2, 1., .1}]}]Rendering can be improved by increasing the depth peeling layers with RenderingOptions:
Style[g, RenderingOptions -> {"DepthPeelingLayers" -> 12}]Alternatively, the graphic can be rendered using a BSP tree, which is slower but has no layer limit:
Style[g, RenderingOptions -> {"3DRenderingMethod" -> "BSPTree"}]Tech Notes
Related Guides
History
Text
Wolfram Research (2007), Opacity, Wolfram Language function, https://reference.wolfram.com/language/ref/Opacity.html.
CMS
Wolfram Language. 2007. "Opacity." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Opacity.html.
APA
Wolfram Language. (2007). Opacity. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Opacity.html
BibTeX
@misc{reference.wolfram_2026_opacity, author="Wolfram Research", title="{Opacity}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/Opacity.html}", note=[Accessed: 15-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_opacity, organization={Wolfram Research}, title={Opacity}, year={2007}, url={https://reference.wolfram.com/language/ref/Opacity.html}, note=[Accessed: 15-June-2026]}