You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add possibility of providing triangles while plotting tricontour #12
I revive a ProPlot issue that is quite limiting in my field.
Context
In Matplotlib, it is possible to plot contours or filled contours using unstructured grid with triangles, using tricontour and tricontourf.
The documentation shows that several ways of providing arguments are available :
ax.tricontourf(x, y, z, ...)
ax.tricontourf(x, y, triangles, z, ...)
ax.tricontourf(triangulation, z, ...)
In the first case, no connectivity is provided and a Delaunay triangulation algorithm is used internally to create triangles. When dealing with concave geometries, this algorithm fills the empty spaces with undesired triangles, and therefore requires to provide the connectivities.
In the second case, an array of connectivity is provided, allowing to deal with concave geometries for example.
In the 3rd case, an object Triangulation is provided, which mainly consists of coordinates and connectivities.
The management of the arguments (with or without the triangles connectivities array) is dealt here in matplotlib.
Anomaly in UltraPlot
However, in pro-ultraplot, tricontour and its filled counterpart only considers (x, y) arguments, and forces the Delaunay triangulation algorithm to be used.
It would be great to modify this behaviour and allow to provide the triangles array or triangulation object as argument of the function.
Thanks for your answer. Here is a simple test code that runs through matplotlib for ways 1 to 3 and only on ultra-lot for way 1.
The case consists in 2 triangles highlighting a concave shape.
I am using the last version of matplotlib, v3.10.0.
Actually, in the second call signature, the "triangles" optional argument can be called, leading to a third case, in a way. But it can also be called just after x and y without keyword.
For information, matplotlib handles the argument in this function here
Activity
cvanelteren commentedon Jan 7, 2025
Can have a look!
cvanelteren commentedon Jan 7, 2025
Could you provide some test code for me to verify the issue @thibaultDrt?
EDIT: for example the issue outlined by you above.
thibaultDrt commentedon Jan 7, 2025
Thanks for your answer. Here is a simple test code that runs through matplotlib for ways 1 to 3 and only on ultra-lot for way 1.
The case consists in 2 triangles highlighting a concave shape.
Using Matplotlib
Here, 3 triangles are created since no connectivity is provided.
By providing the connectivity with only 2 triangles, only these triangles are shown.
Same using the Triangulation object.
Using UltraPlot
Here, the connectivity array argument is not allowed because the positional arguments are necessarily x, y and z.
cvanelteren commentedon Jan 8, 2025
Which version of MPL are you using? The docs state that two call signatures are allowed (here)
PR #13 currently allows those two and I can reproduce your plots with
thibaultDrt commentedon Jan 8, 2025
I am using the last version of matplotlib, v3.10.0.
Actually, in the second call signature, the "triangles" optional argument can be called, leading to a third case, in a way. But it can also be called just after
xandywithout keyword.For information, matplotlib handles the argument in this function here
cvanelteren commentedon Jan 8, 2025
Thanks for all the info! Pushed some changes in the PR that is now ready for review.
cvanelteren commentedon Jan 11, 2025
Fixed in #13