JuliaGeometry / MeshViz.jl

Makie.jl recipes for visualization of Meshes.jl

Home Page:https://github.com/JuliaGeometry/Meshes.jl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wrong aspect ratio for 2D mesh

kylebeggs opened this issue · comments

When visualizing a 2D mesh, the plot comes out with the wrong aspect ratio.

  1. How can you even correct this with the current version? I know with standard Makie you supply a DataAspect() to the axis, but I can't figure out how to do this with this recipe.
  2. This should be the default anyways.

Can you share an example?

The aspect is set like with any other Makie recipe:

fig, ax = viz(obj)
ax.aspect = DataAspect()

Ok, thanks for answering 1, blunder on my part. But regarding 2, the below script does not give the correct aspect

using Meshes
using MeshViz
N = 50
θ = 0:(2π / N):(2π - 2π / (2 * N))
verts = Meshes.Point.(5 * cos.(θ), sin.(θ))
fan_con = [Meshes.connect((1, i, i + 1)) for i in 2:(N - 1)]
m = SimpleMesh(verts, fan_con)
fig, ax = viz(m)

plot_2

and if you do ax.aspect = DataAspect() like you mentioned it does fix it.
plot_fixed

Yes, I think we need to force the DataAspect in the call to the Makie built-in functions. Can you follow the recipe code and try to update the internal function call to Makie to force the aspect? It would be a nice improvement.

image

haha we have come full circle. Yeah, it's not obvious how to do it right away

I find it hard to believe its not possible, but I'm just getting started with Makie/MeshViz so I'm not the best person to try to figure this out. Its certainly not straightforward. Perhaps I make a post on slack or zulip (if they have one)

You have to keep in mind that MeshViz.jl is nothing more and nothing less than Makie recipes. So if something like this is not working, it is not our fault. We are simply calling Makie internal functions to produce specific visualizations for our Meshes.jl types. Try to open an issue in Makie.jl itself if you would like to report that the aspect of the plot can't be changed within recipes.

Yes I understand that, I made a post on the Makie slack and someone said they think it's still not possible so I shall open an issue on Makie.jl.

Closing this issue as it is not related to the recipes we have here.