FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
physics-plot/examples/bode-plot.py at main · c0rychu/physics-plot · GitHub
c0rychu
/
physics-plot
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
2
Code
Issues
1
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
physics-plot
/
examples
/
bode-plot.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
42 lines (32 loc) · 1012 Bytes
Breadcrumbs
physics-plot
/
examples
/
bode-plot.py
Copy path
File metadata and controls
42 lines (32 loc) · 1012 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
33
34
35
36
37
38
39
40
41
42
import
matplotlib
.
pyplot
as
plt
import
numpy
as
np
plt
.
style
.
use
(
"physics_plot.pp_base"
)
# Functions for example plot
def
db
(
x
):
return
20.0
*
np
.
log10
(
x
)
def
model
(
f
):
return
10.0
/
(
f
-
1.0j
*
10
)
# figsize=(x, y), change x and y by yourself!!!
fig
, (
ax_m
,
ax_p
)
=
plt
.
subplots
(
nrows
=
2
,
ncols
=
1
,
figsize
=
(
5
,
3.5
),
constrained_layout
=
True
)
fig
.
suptitle
(
"Low Pass Filter"
)
f
=
np
.
logspace
(
0
,
3
,
1000
)
# Magnitude
ax_m
.
semilogx
(
f
,
db
(
np
.
abs
(
model
(
f
))),
"b"
,
label
=
"LPF"
)
ax_m
.
set_xlim
(
1e0
,
1e3
)
ax_m
.
set_ylabel
(
"Magnitude [dB]"
)
ax_m
.
grid
(
visible
=
True
,
which
=
"major"
)
ax_m
.
grid
(
visible
=
True
,
which
=
"minor"
,
linestyle
=
":"
)
ax_m
.
legend
(
loc
=
1
)
# Phase
ax_p
.
semilogx
(
f
,
np
.
angle
(
model
(
f
),
deg
=
True
),
"b"
,
label
=
"LPF"
)
ax_p
.
set_xlim
(
1e0
,
1e3
)
ax_p
.
set_ylim
(
0
,
90
)
ax_p
.
set_xlabel
(
"Frequency [Hz]"
)
ax_p
.
set_ylabel
(
"Phase [deg]"
)
ax_p
.
grid
(
visible
=
True
,
which
=
"major"
)
ax_p
.
grid
(
visible
=
True
,
which
=
"minor"
,
linestyle
=
":"
)
ax_p
.
legend
(
loc
=
1
)
# fig.tight_layout()
fig
.
savefig
(
"bode-plot@2x.png"
)
Back
|
FazBrowse Home
|
New Git URL