Plot Shape by Value

ziolai
Tue, 29 Jul 2025 19:35:05 +0000
Visualization

Greetings.

I am seeking to extend

using Plots

p1 = [(0., 0.), (1., 0.), (2., 0.)];
p2 = [(1., 0.), (2., 0.), (3., 0.)];
p3 = [(1., 1.), (2., 1.), (3., 1.)];

p = Plots.plot(xlabel = "x", ylabel = "y",legend = false,aspect_ratio = :equal)
for i in 1:3
    triangle = Shape([p1[i], p2[i], p3[i]])
    p = Plots.plot!(p,triangle,fillcolor=:blue, alpha=0.7, linecolor=:black)
end

plot(p)

resulting in

to a version in which the color per triangle is specified by a vector with 3 Float64 numbers.

Thx.

18 posts - 3 participants