Skip to content
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

Merged
merged 6 commits into from Oct 2, 2012

Conversation

dmcdougall
Copy link
Member

This makes Axes3D.plot_trisurf support custom triangulations; with a nice example as well.

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.
@dmcdougall
Copy link
Member Author

This one of a series of pull requests to update the Axes3D.tri* methods.

# TODO: Support masked triangulations
tri = Triangulation(X, Y)
x = tri.x
y = tri.y
triangles = tri.triangles
Copy link
Member

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.

Copy link
Member Author

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.
@dmcdougall
Copy link
Member Author

@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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: determnine -> determine.

@dmcdougall
Copy link
Member Author

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()
Copy link
Member

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.

@dmcdougall
Copy link
Member Author

@ianthomas23 Done. Do I need to add anything to api_changes.rst or whats_new.rst?

@ianthomas23
Copy link
Member

@dmcdougall: I don't think so - it is probably better to do a single entry grouping together all the mplot3d tri* function changes.

ianthomas23 added a commit that referenced this pull request Oct 2, 2012
Update mplot3d trisurf to support custom triangulations.
@ianthomas23 ianthomas23 merged commit 89482b2 into matplotlib:master Oct 2, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants