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
Update trisurf to support custom triangulations #1298
Conversation
This brings plot_trisurf more inline with the 2d tri* method equivalents. An example has also been added to: a) reflect the new support; and b) illustrate the additional flexibility this change enables.
This one of a series of pull requests to update the |
# TODO: Support masked triangulations | ||
tri = Triangulation(X, Y) | ||
x = tri.x | ||
y = tri.y | ||
triangles = tri.triangles |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you use the following instead, you get support for masked triangulations:
triangles = tri.get_masked_triangles()
I haven't fully tested this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thanks for the reminder!
The methods plot_surface
and plot_wireframe
don't currently support masked domains, so this is a big win in my opinion.
An example has also been added (adapted from tripcolor) to illustrate the use of masked triangulations.
@ianthomas23 The masked example looks great. Thanks for the suggestion. |
fig = plt.figure() | ||
ax = fig.add_subplot(1, 1, 1, projection='3d') | ||
|
||
# The triangles in parameter space determnine which x, y, z points are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: determnine -> determine.
Thanks @ianthomas23, I've made the updates. |
ax.plot_trisurf(x, y, z, triangles=tri.triangles, cmap=plt.cm.Spectral) | ||
|
||
ax.set_zlim(-1, 1) | ||
plt.show() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove this line, the one at the end is sufficient. Once you've done this I'll merge the PR.
@ianthomas23 Done. Do I need to add anything to api_changes.rst or whats_new.rst? |
@dmcdougall: I don't think so - it is probably better to do a single entry grouping together all the mplot3d tri* function changes. |
Update mplot3d trisurf to support custom triangulations.
This makes
Axes3D.plot_trisurf
support custom triangulations; with a nice example as well.