FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
matplotlib.github.com/examples/frontpage/plot_3D.py at master · 2236zml/matplotlib.github.com · GitHub
2236zml
/
matplotlib.github.com
Public
forked from
matplotlib/matplotlib.github.com
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
matplotlib.github.com
/
examples
/
frontpage
/
plot_3D.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
38 lines (32 loc) · 1.22 KB
Breadcrumbs
matplotlib.github.com
/
examples
/
frontpage
/
plot_3D.py
Copy path
File metadata and controls
38 lines (32 loc) · 1.22 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
====================
Frontpage 3D example
====================
This example reproduces the frontpage 3D example.
"""
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"
,
dpi
=
25
)
# results in 160x120 px image
Back
|
FazBrowse Home
|
New Git URL