-
-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: trisurf_plot aka mesh3d #392
Comments
For pyplot and gr you can pass 3 vectors with seriestype surface and it On Monday, July 18, 2016, krcools notifications@github.com wrote:
|
Thanks for the quick reply. If IIUC these trisurfs are always structured in the sense that they derive from a rectangular grid, correct? I am looking for functionality that allows me to create unstructured triangular meshes. Typical APIs expect x,y,z values, but in addition also i,j,k integer indices defining the grid. I know that PyPlot, PlotlyJS, and Matlab can do this. |
The whole point of a trisurf is that it's not necessarily a grid. On Monday, July 18, 2016, krcools notifications@github.com wrote:
|
While I agree there's no way to specify arbitrary 3D meshes at this point, the "trisurf" functionality works fine:
As you can see from the example, there's no need for the data to be on a grid, or even ordered in any way. The "trisurf" creates a surface, not a mesh, and this might be your point of confusion? |
Yes, I imagine our communication issues can be traced back to us using slightly different definitions. I'd like to partially shift blame for that to http://matplotlib.org/mpl_examples/mplot3d/trisurf3d_demo2.py Also the https://plot.ly/javascript/trisurf/ What you refer to as |
So do I ;)
Always happy to shift the blame! Yeah I think a "surface" might be on a grid, or not, and I support both types. There is not currently support for 3D meshes, though I'm hopeful @SimonDanisch will help change that. |
OK, let's consider the blame shifted then ;). The feature request stands though, maybe under a different description. Happy to hear it is on the radar! Many thanks! |
That sounds like the most basic primitive of 3D graphics to me :) |
Yes, I showed in #286 how triangles are necessary to make the plotted structure "not fill in". Let me repost the example here with a bit more detail since I don't know if this is getting across.
vs
In that example, you can clearly see the lake, but only when the triangles are specified. However, if you can't specify triangles, it "completes the outside of the structure" to just make a blob (couldn't color the edge lines in GR, but you get the point) This is because surface seems to pair every node together, and get rid of the overlap. However, the whole reason for using trisurf instead of surface is because we know the triangles (big example is FEM codes), and thus without supplying them it's adding "extra" parts to the plot which don't make sense. I can't truly cutoff DifferentialEquations.jl from PyPlot until there is a way to specify the triangles via Plots.jl (and into something like GR or Plotly). |
For you maybe. Not everyone has your perspective and use-case. To be clear... I very much want support for "triangle meshes", but this is different than a "triangle surface". PyPlot makes a mess out of terminology here by combining "surface" and "mesh" into the same function, where you distinguish them by passing in triangles. I would prefer to keep these as separate types. To summarize... please don't ask for surface to be changed... we need a new series type "mesh", and the inputs for that could likely be the triangles you would pass into PyPlot's trisurf. |
I wasn't asking for this to be part of This is pretty common in Finite Element Method (FEM) codes. I know there are a few packages for it on Julia already, and once this is implemented you may wish to start an issue on JuliaFEM for implementing plot recipes for their types. I may get around to this soon. |
Was this solved in #479 ? |
no |
I call the function using FileIO, MakiE, GeometryTypes, MakiE
lakemesh = load(Pkg.dir("DiffEqProblemLibrary", "src", "premade_meshes.jld"))["lakemesh"]
scene = Scene()
# reconstructed type from JLD - not sure were SimpleMesh lives
function MakiE.to_mesh(b, m::typeof(lakemesh))
vertices = map(1:size(m.node, 1)) do i
Point3f0(ntuple(j-> m.node[i, j], Val{2})..., 0)
end
triangles = map(1:size(m.elem, 1)) do i
GLTriangle(Int.(ntuple(j-> m.elem[i, j], Val{3})))
end
GLNormalMesh(vertices, triangles)
end
wireframe(lakemesh)
m = mesh(lakemesh)
center!(scene) result: |
Beautiful! using FileIO, MakiE
lakemesh = load(Pkg.dir("DiffEqProblemLibrary", "src", "premade_meshes.jld"))["lakemesh"]
plot(lakemesh) #or mesh :-) |
well, the overloading of |
awesome. And I'm guessing the |
Why is it a "light" version of a recipe? As a user recipe (given that there weren't one already) I'm guessing it would look like this: Typ = typeof(lakemesh)
@recipe function f(m::Typ)
vertices = map(1:size(m.node, 1)) do i
Point3f0(ntuple(j-> m.node[i, j], Val{2})..., 0)
end
triangles = map(1:size(m.elem, 1)) do i
GLTriangle(Int.(ntuple(j-> m.elem[i, j], Val{3})))
end
GLNormalMesh(vertices, triangles)
end |
Because it just overloads a conversion function and basically works orthogonal to any plotting command (though every plotting command using to_mesh, e.g. wireframe, automatically will get this as well)... |
I'm not sure what you mean with the atomic function recipe? It sounds interesting, though. I just wanted to highlight that recipes are generally a lot simpler than people tend to make them out to be, in particular it's a really easy way to define plotting for a type to define a simple conversion recipe like the above that changes it into a type that does have a recipe. |
Well, this example would proof the point quite nicely, since a macro seems unnecessary here ;) I find it really confusing that this needs a macro, since I don't really know what magic this hides. |
Well, they're like the current |
... and efficient, once your focus is on data analysis and your plot is just a visualization that supports your thought process rather than the end point. That's the beauty of Plots - you have control when you need it, but for all the other plots you do during a workday you just need a ten-char one-liner. |
To me, the |
for what its worth, the way |
Has this feature already been implemented in |
Both GR and PyPlot have a trisurf call in the backend code. |
Closed by #3835 |
Is there a 2D analog of this? |
I really like the idea of this package and I am more and more relying upon it. These is one type of plots however that I encounter very frequently in my work and that does not seem to be supported by plots.jl: an interface for the plotting of triangular meshes in 3d. At least the PyPlot and PlotsJS backends provide support through their
trisurf_plot
andmesh3d
API's, respectively. This leaves me with a mix of Plots calls and direct backend invocations.Is this somehow already supported or are there any plans to support this API in the future?
The text was updated successfully, but these errors were encountered: