Skip to content

Providing some basic visualization tools #14

Open
@bennibolm

Description

@bennibolm

We could add some basic visualization routines using Plots.jl (and create a documentation section about it).

For instance, this is what I use right now:

Plotting only the points:

scatter(data_points[1, :], data_points[2, :], legend=false, title="points")

points

Adding triangulation to the plot:

for element in axes(vertices, 2)
    v1 = vertices[1, element]
    v2 = vertices[2, element]
    v3 = vertices[3, element]
    x1 = data_points[:, v1]
    x2 = data_points[:, v2]
    x3 = data_points[:, v3]
    plot!(p, [x1[1], x2[1]], [x1[2], x2[2]])
    plot!(p, [x2[1], x3[1]], [x2[2], x3[2]])
    plot!(p, [x3[1], x1[1]], [x3[2], x1[2]])
end
plot!(title = "triangles")

points_triangles

Data points and polygons (here with :centroids):

p1 = scatter(data_points[1, :], data_points[2, :], legend=false)
for element_vor in axes(voronoi_vertices_interval, 2)
    vertex_first = voronoi_vertices_interval[1, element_vor]
    vertex_last = voronoi_vertices_interval[2, element_vor]
    for i in vertex_first:(vertex_last-1)
        v1 = voronoi_vertices[i]
        v2 = voronoi_vertices[i + 1]
        x1 = voronoi_vertices_coordinates[:, v1]
        x2 = voronoi_vertices_coordinates[:, v2]
        plot!(p1, [x1[1], x2[1]], [x1[2], x2[2]])
    end
    v1 = voronoi_vertices[vertex_last]
    v2 = voronoi_vertices[vertex_first]
    x1 = voronoi_vertices_coordinates[:, v1]
    x2 = voronoi_vertices_coordinates[:, v2]
    plot!(p1, [x1[1], x2[1]], [x1[2], x2[2]], title="mesh type: $mesh_type")
end

polgonmesh

The variables names are chosen as in the elixirs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions