# Can I get a VertexOpacity-like feature when displaying graphics?

I am wondering: why there is no option for VertexOpacity, while there is for VertexColors?

Graphics[Line[Table[{i, 0.02 i}, {i, 1, 5}], VertexColors -> RandomColor[5]]]


I can use Point, specifying coloring and opacity, but how I can connect them?

I want this feature to plot 10,000,000 points (or equivalently 4000 lines), and I realize the time consumption of the line is less than Point.

• use VertexColors -> MapThread[Append, {RandomColor[5], RandomReal[{0, 1}, 5]}]?
– kglr
Sep 26, 2020 at 4:08
• or VertexColors -> (Opacity[#, Red] & /@ RandomReal[{0, 1}, 5])?
– kglr
Sep 26, 2020 at 4:09
• @kglr, Thanks it seems it works. How can I close this topic? Sep 26, 2020 at 4:26
• If you want, you can write an answer to your own question based on what @kglr wrote, if you understood what he meant. Sep 26, 2020 at 6:04

I prepare the following example based on @kglr comment.

Let's define points as

points = Table[{x, y, Cos[2 x] + Cos[2 y]/2}, {x, 0, 10, 0.1}, {y, 0, 10, 0.1}];


Now plotting points with separate coloring,

Graphics[{Opacity[Abs@#[[3]],
Blend[{{-1, Blue}, {0, Yellow}, {1, Red}}, #[[3]]]],
Point[#[[1 ;; 2]]]} & /@ Flatten[points, 1]]


gives,

using vertexColors,

Graphics[Point[#[[All, 1 ;; 2]],
VertexColors -> (Opacity[Abs@#,
Blend[{{-1, Blue}, {0, Yellow}, {1, Red}}, #]] & /@ #[[All,
3]])] & /@ points]


gives,

and if i interpreter it as a line,

Graphics[Line[#[[All, 1 ;; 2]],
VertexColors -> (Opacity[ Abs@#,
Blend[{{-1, Blue}, {0, Yellow}, {1, Red}}, #]] & /@ #[[All,
3]])] & /@ points]


• To put it another way: if you want to modify the opacity of Line[] objects, you can always use colors that have a set alpha channel. Sep 26, 2020 at 11:18