FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
matplotlib/examples/mplot3d/trisurf3d_demo.py at master · dpsanders/matplotlib · GitHub
dpsanders
matplotlib
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
matplotlib
/
examples
/
mplot3d
/
trisurf3d_demo.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
32 lines (23 loc) · 848 Bytes
Breadcrumbs
matplotlib
/
examples
/
mplot3d
/
trisurf3d_demo.py
Copy path
File metadata and controls
32 lines (23 loc) · 848 Bytes
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
from
mpl_toolkits
.
mplot3d
import
Axes3D
from
matplotlib
import
cm
import
matplotlib
.
pyplot
as
plt
import
numpy
as
np
n_angles
=
36
n_radii
=
8
# An array of radii
# Does not include radius r=0, this is to eliminate duplicate points
radii
=
np
.
linspace
(
0.125
,
1.0
,
n_radii
)
# An array of angles
angles
=
np
.
linspace
(
0
,
2
*
np
.
pi
,
n_angles
,
endpoint
=
False
)
# Repeat all angles for each radius
angles
=
np
.
repeat
(
angles
[...,
np
.
newaxis
],
n_radii
,
axis
=
1
)
# Convert polar (radii, angles) coords to cartesian (x, y) coords
# (0, 0) is added here. There are no duplicate points in the (x, y) plane
x
=
np
.
append
(
0
, (
radii
*
np
.
cos
(
angles
)).
flatten
())
y
=
np
.
append
(
0
, (
radii
*
np
.
sin
(
angles
)).
flatten
())
# Pringle surface
z
=
np
.
sin
(
-
x
*
y
)
fig
=
plt
.
figure
()
ax
=
fig
.
gca
(
projection
=
'3d'
)
ax
.
plot_trisurf
(
x
,
y
,
z
,
cmap
=
cm
.
jet
,
linewidth
=
0.2
)
plt
.
show
()
Back
|
FazBrowse Home
|
New Git URL