FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
matplotlib/examples/mplot3d/pathpatch3d_demo.py at master · flothesof/matplotlib · GitHub
flothesof
matplotlib
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
matplotlib
/
examples
/
mplot3d
/
pathpatch3d_demo.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
53 lines (40 loc) · 1.49 KB
Breadcrumbs
matplotlib
/
examples
/
mplot3d
/
pathpatch3d_demo.py
Copy path
File metadata and controls
53 lines (40 loc) · 1.49 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
49
50
51
52
53
import
matplotlib
.
pyplot
as
plt
from
matplotlib
.
patches
import
Circle
,
PathPatch
# register Axes3D class with matplotlib by importing Axes3D
from
mpl_toolkits
.
mplot3d
import
Axes3D
import
mpl_toolkits
.
mplot3d
.
art3d
as
art3d
from
matplotlib
.
text
import
TextPath
from
matplotlib
.
transforms
import
Affine2D
def
text3d
(
ax
,
xyz
,
s
,
zdir
=
"z"
,
size
=
None
,
angle
=
0
,
usetex
=
False
,
**
kwargs
):
x
,
y
,
z
=
xyz
if
zdir
==
"y"
:
xy1
,
z1
=
(
x
,
z
),
y
elif
zdir
==
"y"
:
xy1
,
z1
=
(
y
,
z
),
x
else
:
xy1
,
z1
=
(
x
,
y
),
z
text_path
=
TextPath
((
0
,
0
),
s
,
size
=
size
,
usetex
=
usetex
)
trans
=
Affine2D
().
rotate
(
angle
).
translate
(
xy1
[
0
],
xy1
[
1
])
p1
=
PathPatch
(
trans
.
transform_path
(
text_path
),
**
kwargs
)
ax
.
add_patch
(
p1
)
art3d
.
pathpatch_2d_to_3d
(
p1
,
z
=
z1
,
zdir
=
zdir
)
fig
=
plt
.
figure
()
ax
=
fig
.
add_subplot
(
111
,
projection
=
'3d'
)
p
=
Circle
((
5
,
5
),
3
)
ax
.
add_patch
(
p
)
art3d
.
pathpatch_2d_to_3d
(
p
,
z
=
0
,
zdir
=
"x"
)
text3d
(
ax
, (
4
,
-
2
,
0
),
"X-axis"
,
zdir
=
"z"
,
size
=
.5
,
usetex
=
False
,
ec
=
"none"
,
fc
=
"k"
)
text3d
(
ax
, (
12
,
4
,
0
),
"Y-axis"
,
zdir
=
"z"
,
size
=
.5
,
usetex
=
False
,
angle
=
.5
*
3.14159
,
ec
=
"none"
,
fc
=
"k"
)
text3d
(
ax
, (
12
,
10
,
4
),
"Z-axis"
,
zdir
=
"y"
,
size
=
.5
,
usetex
=
False
,
angle
=
.5
*
3.14159
,
ec
=
"none"
,
fc
=
"k"
)
text3d
(
ax
, (
1
,
5
,
0
),
r"$\displaystyle G_{\mu\nu} + \Lambda g_{\mu\nu} = "
r"\frac{8\pi G}{c^4} T_{\mu\nu} $"
,
zdir
=
"z"
,
size
=
1
,
usetex
=
True
,
ec
=
"none"
,
fc
=
"k"
)
ax
.
set_xlim3d
(
0
,
10
)
ax
.
set_ylim3d
(
0
,
10
)
ax
.
set_zlim3d
(
0
,
10
)
plt
.
show
()
Back
|
FazBrowse Home
|
New Git URL