How to show edges in mesh plot in Makie?

From the documentation, it is easy to plot a mesh given an array of coordinates and an array of connectivities:

using GLMakie

coords = [
  0.0 0.0
  1.0 0.0
  1.0 1.0
  0.0 1.0
]

connec = [
  1 2 3
  3 4 1
]

mesh(coords, connec)

Is there an attribute to also show the wireframe? I am trying to show the edges of the triangles in black color for example.

1 Like

I got this to work, but I don’t know if that is enough?
The wireframe! method expects a “mesh” object, which I think is built in the call to mesh, you could extract that mesh from inside the mesh plot.

julia> coords = [
         0.0 0.0
         1.0 0.0
         1.0 1.0
         0.0 1.0
       ]

julia> connec = [
         1 2 3
         3 4 1
       ]

julia> a = mesh(coords,connec)

julia> wireframe!(a.axis,a.plot[1][], color=:black)

1 Like

Thank you @Argel_Ramirez_Reyes , but I am wondering if it is possible to use an attribute instead. Perhaps it is not possible currently.

You can use:

poly(coords, connec, strokewidth=1, shading=true)
4 Likes

Nice, I will give it a try. Could you please explain the main differences between poly and mesh? I was assuming that the mesh command was the main command for plotting meshes.

1 Like

It looks like the behavior is more general than mesh. From the docstrings

Plots a polygon based on the arguments given. When vertices and indices are given, it functions similarly to mesh. When points are given, it draws one polygon that connects all the points in order. When a shape is given (essentially anything decomposable by GeometryBasics), it will plot decompose(shape).

Tried both and seems like the strokewidth keyword works for poly but not mesh.

Poly is mesh plus wireframe

1 Like