-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Fix edge color, links, wording; closes matplotlib/matplotlib#23895 #23930
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
Merged
+18
−22
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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 |
|---|---|---|
| @@ -1,30 +1,31 @@ | ||
| """ | ||
| ====================================== | ||
| Projecting filled contour onto a graph | ||
| ====================================== | ||
| =================================== | ||
| Project filled contour onto a graph | ||
| =================================== | ||
|
|
||
| Demonstrates displaying a 3D surface while also projecting filled contour | ||
| 'profiles' onto the 'walls' of the graph. | ||
|
|
||
| See contour3d_demo2 for the unfilled version. | ||
| See :doc:`contour3d_3` for the unfilled version. | ||
| """ | ||
|
|
||
| from mpl_toolkits.mplot3d import axes3d | ||
| import matplotlib.pyplot as plt | ||
| from matplotlib import cm | ||
| from matplotlib.cm import coolwarm as cmap | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above. |
||
|
|
||
| ax = plt.figure().add_subplot(projection='3d') | ||
| X, Y, Z = axes3d.get_test_data(0.05) | ||
|
|
||
| # Plot the 3D surface | ||
| ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3) | ||
| ax.plot_surface(X, Y, Z, edgecolor=cmap(0), lw=0.5, rstride=8, cstride=8, | ||
| alpha=0.3) | ||
|
|
||
| # Plot projections of the contours for each dimension. By choosing offsets | ||
| # that match the appropriate axes limits, the projected contours will sit on | ||
| # the 'walls' of the graph | ||
| ax.contourf(X, Y, Z, zdir='z', offset=-100, cmap=cm.coolwarm) | ||
| ax.contourf(X, Y, Z, zdir='x', offset=-40, cmap=cm.coolwarm) | ||
| ax.contourf(X, Y, Z, zdir='y', offset=40, cmap=cm.coolwarm) | ||
| ax.contourf(X, Y, Z, zdir='z', offset=-100, cmap=cmap) | ||
| ax.contourf(X, Y, Z, zdir='x', offset=-40, cmap=cmap) | ||
| ax.contourf(X, Y, Z, zdir='y', offset=40, cmap=cmap) | ||
|
|
||
| ax.set(xlim=(-40, 40), ylim=(-40, 40), zlim=(-100, 100), | ||
| xlabel='X', ylabel='Y', zlabel='Z') | ||
|
|
||
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.
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.
It's recommended nowadays to use the colormap registry instead of importing from
matplotlib.cm:You could go even one step further and use the string
contour(..., cmap='coolwarm'). Usually, that's the simplest way if you don't need the colormap object itself. Here however, you have thecmap(0)call. I'm tempted to resolve this to an explicit'#3b4cc0'and get rid of the colormap object completely, which IMHO makes the example simpler.But I'll let you choose whether to go all-string or retrieve
cmapfromplt.colormaps.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, that
cmap(0)is bugging me too. I was considering'#3b4cc0'too, but it is too cryptic. Is there some named blue in the neighborhood?https://matplotlib.org/stable/gallery/color/named_colors.html#css-colors
Since I am green blind, I would like to kindly ask you to please help me out here: If you agree, please suggest a named blue instead of
'#3b4cc0'. Thanks!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 try 'mediumblue' which is slightly darker, or 'royalblue' which is a bit lighter.