FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
matplotlib.github.com/mpl_examples/mplot3d/subplot3d_demo.py at master · 2236zml/matplotlib.github.com · GitHub
2236zml
matplotlib.github.com
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
matplotlib.github.com
/
mpl_examples
/
mplot3d
/
subplot3d_demo.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
45 lines (36 loc) · 1.13 KB
Breadcrumbs
matplotlib.github.com
/
mpl_examples
/
mplot3d
/
subplot3d_demo.py
Copy path
File metadata and controls
45 lines (36 loc) · 1.13 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
39
40
41
42
43
44
45
'''
====================
3D plots as subplots
====================
Demonstrate including 3D plots as subplots.
'''
import
matplotlib
.
pyplot
as
plt
from
mpl_toolkits
.
mplot3d
.
axes3d
import
Axes3D
,
get_test_data
from
matplotlib
import
cm
import
numpy
as
np
# set up a figure twice as wide as it is tall
fig
=
plt
.
figure
(
figsize
=
plt
.
figaspect
(
0.5
))
#===============
# First subplot
#===============
# set up the axes for the first plot
ax
=
fig
.
add_subplot
(
1
,
2
,
1
,
projection
=
'3d'
)
# plot a 3D surface like in the example mplot3d/surface3d_demo
X
=
np
.
arange
(
-
5
,
5
,
0.25
)
Y
=
np
.
arange
(
-
5
,
5
,
0.25
)
X
,
Y
=
np
.
meshgrid
(
X
,
Y
)
R
=
np
.
sqrt
(
X
**
2
+
Y
**
2
)
Z
=
np
.
sin
(
R
)
surf
=
ax
.
plot_surface
(
X
,
Y
,
Z
,
rstride
=
1
,
cstride
=
1
,
cmap
=
cm
.
coolwarm
,
linewidth
=
0
,
antialiased
=
False
)
ax
.
set_zlim
(
-
1.01
,
1.01
)
fig
.
colorbar
(
surf
,
shrink
=
0.5
,
aspect
=
10
)
#===============
# Second subplot
#===============
# set up the axes for the second plot
ax
=
fig
.
add_subplot
(
1
,
2
,
2
,
projection
=
'3d'
)
# plot a 3D wireframe like in the example mplot3d/wire3d_demo
X
,
Y
,
Z
=
get_test_data
(
0.05
)
ax
.
plot_wireframe
(
X
,
Y
,
Z
,
rstride
=
10
,
cstride
=
10
)
plt
.
show
()
Back
|
FazBrowse Home
|
New Git URL