How to | Add Transparency to Plots
Transparency is useful in plots when you need an unobstructed view of multiple components of one plot, or simply want to lighten a single plot component against a white background. The Wolfram Language uses the graphics directive Opacity to apply transparency to graphics objects. Opacity can be used with most visualization functions.
Plot[x ^ 2, {x, -2, 2}]Use the PlotStyle option with Opacity to make the plot 70% transparent:
Plot[x ^ 2, {x, -2, 2}, PlotStyle -> Opacity[0.3]]Plot3D[x ^ 4 + y ^ 4 - 5 x ^ 2 * y ^ 2, {x, -3, 3}, {y, -3, 3}]Make the plot 60% transparent:
Plot3D[x ^ 4 + y ^ 4 - 5 x ^ 2 * y ^ 2, {x, -3, 3}, {y, -3, 3}, PlotStyle -> Opacity[0.4]]Add different transparency settings for plots of multiple functions:
Plot3D[{x ^ 4 - 15 x ^ 2 * y ^ 2 + 20 Sin[y], -100 - x ^ 4 - y ^ 4 + 5 x ^ 2 * y ^ 2}, {x, -3, 3}, {y, -3, 3}, PlotStyle -> {{Blue, Opacity[0.5]}, {Yellow, Opacity[0.2]}},
Mesh -> None]Here is a 2D region determined by two inequalities:
RegionPlot[{Sin[x]Cos[y] + 1 / 16 ≥ 0, Sin[x]Sin[y] + 1 / 16 ≥ 0}, {x, -3 Pi, 3Pi}, {y, -3Pi, 3Pi}, PlotStyle -> {Red, Blue}]Make the plot 50% transparent:
RegionPlot[{Sin[x]Cos[y] + 1 / 16 ≥ 0, Sin[x]Sin[y] + 1 / 16 ≥ 0}, {x, -3 Pi, 3Pi}, {y, -3Pi, 3Pi}, PlotStyle -> {{Red, Opacity[0.5]}, {Blue, Opacity[0.5]}}
]Use Opacity to see the inner parts of a plot:
SphericalPlot3D[{1, 2, 3}, {θ, 0, Pi}, {ϕ, 0, 7Pi / 4}, PlotStyle -> Opacity[0.4]]Use the ContourStyle option of ContourPlot3D with Opacity:
ContourPlot3D[x ^ 4 + y ^ 4 + z ^ 4 - (x ^ 2 + y ^ 2 + z ^ 2) ^ 2 + 3(x ^ 2 + y ^ 2 + z ^ 2) == 3, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, Mesh -> None, ContourStyle -> {Orange, Opacity[0.5]}
]You can also add transparency to graphics.
Graphics[{Opacity[0.25], Disk[{0, 0}, 1]}]Opacity can have values between 0 and 1, with 0 corresponding to perfect transparency:
Graphics[{Opacity[1], Disk[{0, 0}, 1], Opacity[0.5], Disk[{.5, 0}, 1], Opacity[0.1], Disk[{1, 0}, 1]}]Use Opacity with a color:
Graphics[{Red, Opacity[1], Disk[{0, 0}, 1], Opacity[0.5], Disk[{.5, 0}, 1], Opacity[0.1], Disk[{1, 0}, 1]}]Opacity interacts well with other Wolfram Language functions:
Manipulate[RegionPlot[{x - y ≥ t, x + y ≥ s}, {x, -3 Pi, 3 Pi}, {y, -3 Pi, 3 Pi}, PlotPoints -> 30, PlotStyle -> {Directive[Red], Directive[Blue, Opacity[0.5]]}], Style["Solving the system of inequalities: x-y ≥ t and x +y ≥ s", Bold, 12], {{s, 0}, -20, 20}, {{t, 0}, -20, 20}]