# How to color the nodes of a quadrilateral polygon

say we have the list of points a = {{1, 1}, {2, 1}, {2, 2}, {1, 2}, {1, 1}}，it is a simple square, how can we make color the nodes( in which that the nodes and the color on them are clearly seen and stand out from the vertexes), also this step will not affect the subsequent coloring of the edges and the interior?

• For a Polygon you do not need to close the path, i.e., either Polygon[Most[a]] or Polygon[Rest[a]] will each draw the Polygon. If you want an unfilled polygon then Line[a] will need a closed path. – Bob Hanlon Nov 7 '18 at 0:56

You can also use VertexColors:

colors = {Red, Green, Blue, Orange, Red};
Graphics[{FaceForm[Opacity[.5, Yellow]], Polygon@a,
AbsolutePointSize[20], Point[a, VertexColors -> colors],
Thick, Gray, Line@a}]


Graphics[{FaceForm[Opacity[.5, Yellow]], Polygon@a,
AbsolutePointSize[20], Thickness[.02],
Through[{Point, Line}[a,  VertexColors -> colors]]}]


• Thanks! This is so helpful! – Chonglin Zhu Nov 6 '18 at 22:14
• @ChonglinZhu, my pleasure. Welcome to mma.se. – kglr Nov 6 '18 at 22:15
Graphics[{Red, PointSize[0.05], Point /@ a}]


or

Graphics[{Red, PointSize[0.05], (Point /@ a), Green, Line[a]}]


• Thanks! This is very useful, but how to color the four nodes differently use different colors? – Chonglin Zhu Nov 6 '18 at 20:23
• I am having difficulty with understanding what you asking. 1) Why do you give a list of five pairs to define a square when four will do? 2) You seem to make a distinction between nodes and vertexes. Could you make that distinction clear? 3) You mention coloring edges at some later time. That and other things mentioned make me ask: are you concerned more about a graph theory object than about graphics object? Please edit your question to put me straight. – m_goldberg Nov 6 '18 at 20:37
• Also, it would be very useful if you add an image showing how the final result should look. – m_goldberg Nov 6 '18 at 20:38
• (1): By five points I meant to draw a closed polygon, as you can see the last point is the same as the first point,.I want to paint the edges and the nodes at the same time, and without the two affecting each hopefully, and I do not know if I can do all these in a nested "Polygon" function, Therefore – Chonglin Zhu Nov 6 '18 at 22:03