Skip to content

Commit 8349813

Browse files
authored
Merge pull request #7541 from NelleV/5654_staticimages
DOC: new static images for the frontpage
2 parents fb4b061 + 87c08b5 commit 8349813

8 files changed

+119
-0
lines changed

doc/_static/contour_frontpage.png

-10.6 KB
Loading

doc/_static/histogram_frontpage.png

26 Bytes
Loading

doc/_static/membrane_frontpage.png

-642 Bytes
Loading

doc/_static/surface3d_frontpage.png

-11 KB
Loading

examples/frontpage/plot_3D.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""
2+
====================
3+
Frontpage 3D example
4+
====================
5+
6+
This example reproduces the frontpage 3D example.
7+
8+
"""
9+
from mpl_toolkits.mplot3d import Axes3D
10+
from matplotlib import cbook
11+
from matplotlib import cm
12+
from matplotlib.colors import LightSource
13+
import matplotlib.pyplot as plt
14+
import numpy as np
15+
16+
filename = cbook.get_sample_data('jacksboro_fault_dem.npz', asfileobj=False)
17+
with np.load(filename) as dem:
18+
z = dem['elevation']
19+
nrows, ncols = z.shape
20+
x = np.linspace(dem['xmin'], dem['xmax'], ncols)
21+
y = np.linspace(dem['ymin'], dem['ymax'], nrows)
22+
x, y = np.meshgrid(x, y)
23+
24+
region = np.s_[5:50, 5:50]
25+
x, y, z = x[region], y[region], z[region]
26+
27+
fig, ax = plt.subplots(subplot_kw=dict(projection='3d'), figsize=(1.62, 1.38))
28+
29+
ls = LightSource(270, 45)
30+
# To use a custom hillshading mode, override the built-in shading and pass
31+
# in the rgb colors of the shaded surface calculated from "shade".
32+
rgb = ls.shade(z, cmap=cm.gist_earth, vert_exag=0.1, blend_mode='soft')
33+
surf = ax.plot_surface(x, y, z, rstride=1, cstride=1, facecolors=rgb,
34+
linewidth=0, antialiased=False, shade=False)
35+
ax.set_xticks([])
36+
ax.set_yticks([])
37+
ax.set_zticks([])
38+
fig.savefig("surface3d_frontpage.png")

examples/frontpage/plot_contour.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""
2+
=========================
3+
Frontpage contour example
4+
=========================
5+
6+
This example reproduces the frontpage contour example.
7+
"""
8+
9+
import matplotlib.pyplot as plt
10+
import numpy as np
11+
from matplotlib import mlab, cm
12+
13+
extent = (-3, 3, -3, 3)
14+
15+
delta = 0.5
16+
x = np.arange(-3.0, 4.001, delta)
17+
y = np.arange(-4.0, 3.001, delta)
18+
X, Y = np.meshgrid(x, y)
19+
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, -0.5)
20+
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
21+
Z = (Z1 - Z2) * 10
22+
23+
levels = np.linspace(-2.0, 1.601, 40)
24+
norm = cm.colors.Normalize(vmax=abs(Z).max(), vmin=-abs(Z).max())
25+
26+
fig, ax = plt.subplots(figsize=(1.62, 1.38))
27+
cset1 = ax.contourf(
28+
X, Y, Z, levels,
29+
norm=norm)
30+
ax.set_xlim(-3, 3)
31+
ax.set_ylim(-3, 3)
32+
ax.set_xticks([])
33+
ax.set_yticks([])
34+
fig.savefig("contour_frontpage.png")

examples/frontpage/plot_histogram.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""
2+
===========================
3+
Frontpage histogram example
4+
===========================
5+
6+
This example reproduces the frontpage histogram example.
7+
"""
8+
9+
import matplotlib.pyplot as plt
10+
import numpy as np
11+
12+
13+
random_state = np.random.RandomState(19680801)
14+
X = random_state.randn(10000)
15+
16+
fig, ax = plt.subplots(figsize=(1.62, 1.38))
17+
ax.hist(X, bins=25, normed=True)
18+
x = np.linspace(-5, 5, 1000)
19+
ax.plot(x, 1 / np.sqrt(2*np.pi) * np.exp(-(x**2)/2), linewidth=4)
20+
ax.set_xticks([])
21+
ax.set_yticks([])
22+
fig.savefig("histogram_frontpage.png")

examples/frontpage/plot_membrane.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
======================
3+
Frontpage plot example
4+
======================
5+
6+
7+
This example reproduces the frontpage simple plot example.
8+
"""
9+
10+
import matplotlib.pyplot as plt
11+
import matplotlib.cbook as cbook
12+
import numpy as np
13+
14+
15+
datafile = cbook.get_sample_data('membrane.dat', asfileobj=False)
16+
x = np.fromfile(datafile, np.float32)
17+
# 0.0005 is the sample interval
18+
19+
fig, ax = plt.subplots(figsize=(1.62, 1.38))
20+
ax.plot(x, linewidth=4)
21+
ax.set_xlim(5000, 6000)
22+
ax.set_ylim(-0.6, 0.1)
23+
ax.set_xticks([])
24+
ax.set_yticks([])
25+
fig.savefig("membrane_frontpage.png")

0 commit comments

Comments
 (0)