is an option for graphics primitives which specifies the colors to assign to vertices.
VertexColors
is an option for graphics primitives which specifies the colors to assign to vertices.
Details
- VertexColors can be used with Polygon, Line, Tube, Point, and GraphicsComplex.
- VertexColors->{col1,col2,…} specifies that color coli should be assigned to vertex i.
- The interior of the polygon is colored by interpolating between the colors specified by VertexColors.
- In 3D, settings for VertexColors can include any surface or material property, to be used with simulated lighting.
- The colors coli for each vertex can be an explicit color directive such as GrayLevel[g] or RGBColor[r,g,b] or can have the following forms:
-
g GrayLevel[g] {g,a} GrayLevel[g,a] {r,g,b} RGBColor[r,g,b] {r,g,b,a} RGBColor[r,g,b,a]
Examples
open all close allBasic Examples (3)
Graphics[Polygon[{{0, 0}, {0, 1}, {1, 1}, {1, 0}}, VertexColors -> {Blue, Green, Brown, Purple}]]Graphics3D[{Polygon[{{0, 0, 0}, {1, 1, 0}, {0, 1, 1}}, VertexColors -> {Blue, Yellow, Orange}]}]Graphics[{Thick, Line[{{0, 0}, {1, 1}, {2, 0}}, VertexColors -> {StandardRed, StandardYellow, StandardGreen}]}]Scope (17)
Graphics Objects (5)
Graphics[Polygon[{{-1, 0}, {1, 0}, {0, Sqrt[3]}}, VertexColors -> {Red, Green, Blue}]]Graphics[Polygon[{{{-1, 0}, {1, 0}, {0, Sqrt[3]}}, {{2, 0}, {4, 0}, {3, Sqrt[3]}}}, VertexColors -> {{Red, Green, Blue}, {Yellow, Cyan, Magenta}}]]Line:
Graphics[{Thick, Line[{{0, 0}, {2, 1}}, VertexColors -> {Red, Green}]}]Graphics[{Thick, Line[{{{0, 0}, {2, 1}}, {{1, 0}, {3, 1}}}, VertexColors -> {{Red, Green}, {Yellow, Blue}}]}]Graphics[{PointSize[0.1], Point[{{0, 0}, {1, 1}, {2, 2}}, VertexColors -> {StandardRed, StandardYellow, StandardBlue}]}]Graphics[{Triangle[{{0, 0}, {0, 1}, {1, 1}}, VertexColors -> {Red, Green, Blue}]}]Graphics[{Triangle[{{{0, 0}, {0, 1}, {1, 1}}, {{2, 0}, {2, 1}, {3, 1}}}, VertexColors -> {{Red, Green, Blue}, {Yellow, Cyan, Magenta}}]}]In a GraphicsComplex, colors can be assigned for shared vertices:
Graphics[{GraphicsComplex[{{0, 0}, {1, 0}, {0, 1}, {1, 1}, {.5, .5}}, {Polygon[{1, 2, 5}], Polygon[{3, 4, 5}]}, VertexColors -> {LightRed, DarkRed, LightBlue, DarkBlue, Purple}]}]Graphics3D primitives and Shapes (5)
Graphics3D[Polygon[{{0, -1, 0}, {0, 1, 0}, {-1, 0, 1}}, VertexColors -> {Red, Green, Blue}]]Graphics3D[Polygon[{{{0, -1, 0}, {0, 1, 0}, {-1, 0, 1}}, {{0, -1, 1}, {0, 1, 1}, {-1, 0, 2}}}, VertexColors -> {{Red, Green, Blue}, {Cyan, Magenta, Yellow}}]]Line:
Graphics3D[{Thick, Line[{{0, 0, 0}, {1, 1, 1}, {2, 2, 1}}, VertexColors -> {Red, Green, Yellow}]}]Graphics3D[{Thick, Line[{{{0, 0, 0}, {2, 1, 1}}, {{1, 0, 0}, {3, 1, 1}}}, VertexColors -> {{Red, Green}, {Blue, Yellow}}]}]Tube:
Graphics3D[{Tube[{{0, 0, 0}, {1, 1, 1}, {2, 2, 1}}, 0.1, VertexColors -> {Red, Green, Yellow}]}]Graphics3D[{Tube[{{{0, 0, 0}, {2, 1, 1}}, {{1, 0, 0}, {3, 1, 1}}}, .2, VertexColors -> {{Red, Green}, {Blue, Yellow}}]}]Graphics3D[{PointSize[0.1], Point[{{0, 0, 0}, {1, 1, 1}, {2, 1, 0}}, VertexColors -> {StandardRed, StandardGreen, StandardOrange}]}, PlotRangePadding -> .1]In a GraphicsComplex, colors can be assigned for shared vertices:
v = {{0, 0, 0}, {2, 0, 0}, {2, 2, 0}, {0, 2, 0}, {1, 1, 2}};i = {{1, 2, 5}, {2, 3, 5}, {3, 4, 5}, {4, 1, 5}};Graphics3D[{GraphicsComplex[v, Polygon[i], VertexColors -> {Red, Green, Yellow, Blue, Opacity[.8, White]}]}]Color Specification (5)
Color directives can have different values for opacity:
Graphics3D[Polygon[{{0, -1, 0}, {0, 1, 0}, {-1, 0, 1}}, VertexColors -> {RGBColor[0, 1, 0, .1], RGBColor[0, 1, 0, .4], RGBColor[0, 1, 0, .9]}]]Directive can be used to combine a color with Opacity:
Graphics3D[Polygon[{{0, -1, 0}, {0, 1, 0}, {-1, 0, 1}}, VertexColors -> {Red, Green, Directive[Blue, Opacity[.5]]}]]Color directives representing different color spaces can be mixed:
Graphics[Polygon[{{0, -1}, {0, 1}, {-1, 0}}, VertexColors -> {RGBColor[0, 1, 0], GrayLevel[.2], LABColor[.6, .5, 1]}]]LightDarkSwitched specifications can be used:
g = Graphics[{Thickness[.1], Line[{{0, 0}, {1, 1}}, VertexColors -> {LightDarkSwitched[LightRed, LightBlue], LightDarkSwitched[DarkRed, DarkBlue]}]}];
{Rasterize[g, LightDark -> "Light"], Rasterize[g, LightDark -> "Dark"]}Use a raw number list to specify {red,green,blue} instead of RGBColor:
Graphics[{Polygon[{{0, 0}, {0, 1}, {2, 0}}, VertexColors -> {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}]}]Similarly, specify {red,green,blue,opacity}:
Graphics[{Polygon[{{0, 0}, {0, 1}, {2, 0}}, VertexColors -> {{1, 0, 0, .1}, {0, 1, 0.9}, {0, 0, 1, .5}}]}]To specify gray levels, use {gray1,gray2,…}
Graphics[{Polygon[{{0, 0}, {0, 1}, {2, 0}}, VertexColors -> {.1, .9, .4}]}]Gray level with opacity is specified as {gray,opacity}
Graphics[{Polygon[{{0, 0}, {0, 1}, {2, 0}}, VertexColors -> {{.5, 0}, {.5, 1}, {.5, .5}}]}]Visualization Functions (2)
ListPlot3D[{{0, 0, 1}, {1, 0, 0}, {0, 1, 0}}, VertexColors -> {Red, Green, Blue}, Lighting -> "Neutral"]ListDensityPlot[{{0, 0, 1}, {1, 0, 0}, {0, 1, 0}}, VertexColors -> {Red, Green, Blue}]Possible Issues (2)
Vertex colors specified within segments of a FilledCurve are ignored:
Graphics[{EdgeForm[Thick], Pink, FilledCurve[Line[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, VertexColors -> {Red, Green, Blue, Yellow}]]}]A VertexColors list that is too short uses the default color for remaining points:
Graphics[{Polygon[{{0, 0}, {1, 1}, {2, 0}}, VertexColors -> {StandardOrange, StandardBlue}]}]If the default primitive color has been changed by a directive, that will be used:
Graphics[{StandardPurple, Polygon[{{0, 0}, {1, 1}, {2, 0}}, VertexColors -> {StandardOrange, StandardBlue}]}]Neat Examples (2)
Create opacity gradients on 3D polygons:
PolyhedronData["GreatRhombicosidodecahedron"] /. Polygon[x_] :> Polygon[x, VertexColors -> Map[Opacity[If[EvenQ[#], 0, 1], White]&, x, {-1}]]Use an image from ExampleData:
pic = Reverse[ExampleData[{"TestImage", "Sailboat"}, "Data"] / 255.];Plot the dataset with vertex colors, simulating the texture:
ListPlot3D[Table[x + Sin[x y], {x, -5, 5, .1}, {y, -5, 5, .1}], Mesh -> None, VertexColors -> {pic[[5 ;; -5 ;; 5, 5 ;; -5 ;; 5]]}, Lighting -> "Neutral"]See Also
Related Guides
-
▪
- 3D Graphics Options ▪
- Colors ▪
- Polygons ▪
- Polyhedra
Text
Wolfram Research (2007), VertexColors, Wolfram Language function, https://reference.wolfram.com/language/ref/VertexColors.html (updated 2008).
CMS
Wolfram Language. 2007. "VertexColors." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2008. https://reference.wolfram.com/language/ref/VertexColors.html.
APA
Wolfram Language. (2007). VertexColors. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/VertexColors.html
BibTeX
@misc{reference.wolfram_2026_vertexcolors, author="Wolfram Research", title="{VertexColors}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/VertexColors.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_vertexcolors, organization={Wolfram Research}, title={VertexColors}, year={2008}, url={https://reference.wolfram.com/language/ref/VertexColors.html}, note=[Accessed: 13-June-2026]}