FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
matplotlib/examples/mplot3d/mixed_subplots.py at master · Nodd/matplotlib · GitHub
Nodd
matplotlib
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
matplotlib
/
examples
/
mplot3d
/
mixed_subplots.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
48 lines (36 loc) · 1.06 KB
Breadcrumbs
matplotlib
/
examples
/
mplot3d
/
mixed_subplots.py
Copy path
File metadata and controls
48 lines (36 loc) · 1.06 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
46
47
48
"""
=================================
2D and 3D *Axes* in same *Figure*
=================================
This example shows a how to plot a 2D and 3D plot on the same figure.
"""
from
mpl_toolkits
.
mplot3d
import
Axes3D
import
matplotlib
.
pyplot
as
plt
import
numpy
as
np
def
f
(
t
):
s1
=
np
.
cos
(
2
*
np
.
pi
*
t
)
e1
=
np
.
exp
(
-
t
)
return
np
.
multiply
(
s1
,
e1
)
# Set up a figure twice as tall as it is wide
fig
=
plt
.
figure
(
figsize
=
plt
.
figaspect
(
2.
))
fig
.
suptitle
(
'A tale of 2 subplots'
)
# First subplot
ax
=
fig
.
add_subplot
(
2
,
1
,
1
)
t1
=
np
.
arange
(
0.0
,
5.0
,
0.1
)
t2
=
np
.
arange
(
0.0
,
5.0
,
0.02
)
t3
=
np
.
arange
(
0.0
,
2.0
,
0.01
)
ax
.
plot
(
t1
,
f
(
t1
),
'bo'
,
t2
,
f
(
t2
),
'k--'
,
markerfacecolor
=
'green'
)
ax
.
grid
(
True
)
ax
.
set_ylabel
(
'Damped oscillation'
)
# Second subplot
ax
=
fig
.
add_subplot
(
2
,
1
,
2
,
projection
=
'3d'
)
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
,
linewidth
=
0
,
antialiased
=
False
)
ax
.
set_zlim
(
-
1
,
1
)
plt
.
show
()
Back
|
FazBrowse Home
|
New Git URL