Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
[mplot3d] Add custom values for determining colors in trisurf#23878
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
aaarne wants to merge7 commits intomatplotlib:mainChoose a base branch fromaaarne:main
base:main
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Open
Changes fromall commits
Commits
Show all changes
7 commits Select commitHold shift + click to select a range
08c2944
Add custom values for determining colors in trisurf
aaarne31eee23
Make flake8 conform
aaarnee516dbb
Rename values to C
aaarne0da69be
Add test for colored plot_trisurf
aaarnef5f2238
Add facecolor kw to plot_trisurf
aaarne43900cb
Rename color keyword argument of plot_trisurf from c to C
aaarneef8b315
State that values will be color-mapped in tripcolor
aaarneFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
35 changes: 35 additions & 0 deletionsdoc/users/next_whats_new/colored_trisurf.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
3D Trisurf plots can now have colors and allow color-maps | ||
--------------------------------------------------------- | ||
We can now show custom properties on triangle surface in 3D color coded. | ||
You can provide an array of one value per vertex OR one value per face. | ||
The faces will then be painted based on a color map. If one value per vertex | ||
is specified (this is probably the default case, as we usually know data only on | ||
the vertices) the vertex values will be averaged over the face an then color-mapped. | ||
Now also shading of colored trisurfs is added. Before it was only possible for uniformly | ||
colored meshes. This might not be what you want on colormaps, so the default is off. | ||
.. plot:: | ||
:include-source: true | ||
import numpy as np | ||
import matplotlib.tri as mtri | ||
import matplotlib.pyplot as plt | ||
fig = plt.figure() | ||
# Create a parametric sphere | ||
r = np.linspace(0, np.pi, 50) | ||
phi = np.linspace(-np.pi, np.pi, 50) | ||
r, phi = np.meshgrid(r, phi) | ||
r, phi = r.flatten(), phi.flatten() | ||
tri = mtri.Triangulation(r, phi) | ||
x = np.sin(r)*np.cos(phi) | ||
y = np.sin(r)*np.sin(phi) | ||
z = np.cos(r) | ||
ax = fig.add_subplot(projection='3d') | ||
ax.plot_trisurf(x, y, z, triangles=tri.triangles, C=phi, cmap=plt.cm.get_cmap('terrain')) | ||
plt.show() |
35 changes: 35 additions & 0 deletionsexamples/mplot3d/trisurf3d_3.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
""" | ||
=========================== | ||
Colored triangular 3D surfaces | ||
=========================== | ||
This shows how to do colored trisurf plots. | ||
""" | ||
import numpy as np | ||
import matplotlib.tri as mtri | ||
import matplotlib.pyplot as plt | ||
fig = plt.figure() | ||
# Create a parametric sphere | ||
r = np.linspace(0, np.pi, 50) | ||
phi = np.linspace(-np.pi, np.pi, 50) | ||
r, phi = np.meshgrid(r, phi) | ||
r, phi = r.flatten(), phi.flatten() | ||
tri = mtri.Triangulation(r, phi) | ||
x = np.sin(r)*np.cos(phi) | ||
y = np.sin(r)*np.sin(phi) | ||
z = np.cos(r) | ||
ax = fig.add_subplot(projection='3d') | ||
ax.plot_trisurf(x, y, z, | ||
triangles=tri.triangles, | ||
cmap=plt.colormaps['terrain'], | ||
C=np.sin(2*phi)*(r - np.pi/2), | ||
shade=True) | ||
fig.tight_layout() | ||
plt.show() |
2 changes: 1 addition & 1 deletionlib/matplotlib/tri/tripcolor.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
86 changes: 65 additions & 21 deletionslib/mpl_toolkits/mplot3d/axes3d.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletionslib/mpl_toolkits/tests/test_mplot3d.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.