-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
ENH new static images for the frontpage #7541
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
Merged
Changes from 1 commit
Commits
Show all changes
4 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
Next
Next commit
ENH new static images for the frontpage
Here is the code to produce the new static images for the website frontpage
- Loading branch information
commit 44a6d1d720bc592509017365524aa5fcb73f7c1c
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
""" | ||
Demonstrates using custom hillshading in a 3D surface plot. | ||
""" | ||
from mpl_toolkits.mplot3d import Axes3D | ||
from matplotlib import cbook | ||
from matplotlib import cm | ||
from matplotlib.colors import LightSource | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
filename = cbook.get_sample_data('jacksboro_fault_dem.npz', asfileobj=False) | ||
with np.load(filename) as dem: | ||
z = dem['elevation'] | ||
nrows, ncols = z.shape | ||
x = np.linspace(dem['xmin'], dem['xmax'], ncols) | ||
y = np.linspace(dem['ymin'], dem['ymax'], nrows) | ||
x, y = np.meshgrid(x, y) | ||
|
||
region = np.s_[5:50, 5:50] | ||
x, y, z = x[region], y[region], z[region] | ||
|
||
fig, ax = plt.subplots(subplot_kw=dict(projection='3d')) | ||
|
||
ls = LightSource(270, 45) | ||
# To use a custom hillshading mode, override the built-in shading and pass | ||
# in the rgb colors of the shaded surface calculated from "shade". | ||
rgb = ls.shade(z, cmap=cm.gist_earth, vert_exag=0.1, blend_mode='soft') | ||
surf = ax.plot_surface(x, y, z, rstride=1, cstride=1, facecolors=rgb, | ||
linewidth=0, antialiased=False, shade=False) | ||
ax.set_xticks([]) | ||
ax.set_yticks([]) | ||
ax.set_zticks([]) | ||
fig.savefig("surface3D_frontpage.png") |
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,29 @@ | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
from matplotlib import mlab, cm | ||
|
||
# Default delta is large because that makes it fast, and it illustrates | ||
# the correct registration between image and contours. | ||
delta = 0.5 | ||
|
||
extent = (-3, 3, -3, 3) | ||
|
||
x = np.arange(-3.0, 4.001, delta) | ||
y = np.arange(-4.0, 3.001, delta) | ||
X, Y = np.meshgrid(x, y) | ||
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, -0.5) | ||
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1) | ||
Z = (Z1 - Z2) * 10 | ||
|
||
levels = np.linspace(-2.0, 1.601, 40) | ||
norm = cm.colors.Normalize(vmax=abs(Z).max(), vmin=-abs(Z).max()) | ||
|
||
fig, ax = plt.subplots() | ||
cset1 = ax.contourf( | ||
X, Y, Z, levels, | ||
norm=norm) | ||
ax.set_xlim(-3, 3) | ||
ax.set_ylim(-3, 3) | ||
ax.set_xticks([]) | ||
ax.set_yticks([]) | ||
fig.savefig("contour_frontpage.png") |
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,14 @@ | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
|
||
random_state = np.random.RandomState(19680801) | ||
X = random_state.randn(10000) | ||
|
||
fig, ax = plt.subplots() | ||
ax.hist(X, bins=25, normed=True) | ||
x = np.linspace(-5, 5, 1000) | ||
ax.plot(x, 1 / np.sqrt(2*np.pi) * np.exp(-(x**2)/2), linewidth=4) | ||
ax.set_xticks([]) | ||
ax.set_yticks([]) | ||
fig.savefig("histogram_frontpage.png") |
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,16 @@ | ||
import matplotlib.pyplot as plt | ||
import matplotlib.cbook as cbook | ||
import numpy as np | ||
|
||
|
||
datafile = cbook.get_sample_data('membrane.dat', asfileobj=False) | ||
x = np.fromstring(open(datafile, 'rb').read(), np.float32) | ||
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.
|
||
# 0.0005 is the sample interval | ||
|
||
fig, ax = plt.subplots() | ||
ax.plot(x, linewidth=4) | ||
ax.set_xlim(5000, 6000) | ||
ax.set_ylim(-0.6, 0.1) | ||
ax.set_xticks([]) | ||
ax.set_yticks([]) | ||
fig.savefig("membrane_frontpage.png") |
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.
There's an image?