-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add possibility of providing triangles while plotting tricontour #12
Comments
Can have a look! |
Could you provide some test code for me to verify the issue @thibaultDrt? |
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. import matplotlib.pyplot as plt
import matplotlib.tri as tri
import numpy as np x = np.array([0, 1, 0, 0, 1])
y = np.array([0, 0, 1, 2, 2])
z = np.array([0, 1, -1, 0, 2])
conn = np.array([
[0, 1, 2],
[2, 3, 4],
]) Using MatplotlibHere, 3 triangles are created since no connectivity is provided. fig, ax = plt.subplots(figsize=(4, 3))
ax.tricontourf(x, y, z, levels=64, cmap="PuBu")
ax.triplot(x, y, "ko-") # To display cell edges
By providing the connectivity with only 2 triangles, only these triangles are shown. fig, ax = plt.subplots(figsize=(4, 3))
ax.tricontourf(x, y, conn, z, levels=64, cmap="PuBu")
ax.triplot(x, y, conn, "ko-") # To display cell edges
Same using the Triangulation object. triangulation = tri.Triangulation(x, y, conn)
fig, ax = plt.subplots(figsize=(4, 3))
ax.tricontourf(triangulation, z, levels=64, cmap="PuBu")
ax.triplot(triangulation, "ko-") # To display cell edges
Using UltraPlotimport ultraplot as uplot fig, ax = uplot.subplot()
ax.tricontourf(x, y, z, cmap="PuBu", levels=64, ec="none")
ax.triplot(x, y)
Here, the connectivity array argument is not allowed because the positional arguments are necessarily x, y and z. fig, ax = uplot.subplot()
ax.tricontourf(x, y, conn, z, cmap="PuBu", levels=64, ec="none")
ax.triplot(x, y, conn)
triangulation = tri.Triangulation(x, y, conn)
fig, ax = uplot.subplot()
ax.tricontourf(triangulation, z, cmap="PuBu", levels=64, ec="none")
ax.triplot(triangulation)
|
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 import ultraplot as plt, numpy as np
x = np.array([0, 1, 0, 0, 1])
y = np.array([0, 0, 1, 2, 2])
z = np.array([0, 1, -1, 0, 2])
conn = np.array([
[0, 1, 2],
[2, 3, 4],
])
fig, ax = plt.subplots(figsize=(4, 3))
ax.tricontourf(x, y, z, triangles = conn, levels=64, cmap="PuBu")
ax.triplot(x, y, conn, "ko-") # To display cell edges
fig, ax = plt.subplots(figsize=(4, 3))
ax.tricontourf(x, y, z, levels=64, cmap="PuBu")
ax.triplot(x, y, "ko-") # To display cell edges |
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 For information, matplotlib handles the argument in this function here |
Thanks for all the info! Pushed some changes in the PR that is now ready for review. |
Fixed in #13 |
Hello there,
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 :
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 ortriangulation
object as argument of the function.Thanks a lot for the help :)
The text was updated successfully, but these errors were encountered: