Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BEA data analysis utils
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Philipp Niedermayer
BEA data analysis utils
Commits
05036561
Commit
05036561
authored
2 years ago
by
Philipp Niedermayer
Browse files
Options
Downloads
Patches
Plain Diff
Indicate window sizes on plots
parent
e6d10897
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
plotting.py
+16
-3
16 additions, 3 deletions
plotting.py
with
16 additions
and
3 deletions
plotting.py
+
16
−
3
View file @
05036561
...
...
@@ -121,6 +121,20 @@ def format_axis_radians(yaxis):
yaxis
.
set_major_formatter
(
mpl
.
ticker
.
FuncFormatter
(
lambda
x
,
p
:
'
0
'
if
x
==
0
else
'
$
\\
pi$
'
if
x
==
np
.
pi
else
'
$-
\\
pi$
'
if
x
==-
np
.
pi
else
f
'
$
{
x
/
np
.
pi
:
g
}
\\
pi$
'
))
yaxis
.
set_minor_formatter
(
mpl
.
ticker
.
FuncFormatter
(
lambda
x
,
p
:
'
0
'
if
x
==
0
else
'
$
\\
pi$
'
if
x
==
np
.
pi
else
'
$-
\\
pi$
'
if
x
==-
np
.
pi
else
None
))
def
format_axis_degrees
(
yaxis
):
yaxis
.
set_major_locator
(
mpl
.
ticker
.
MaxNLocator
(
'
auto
'
,
steps
=
[
1
,
1.5
,
3
,
6
,
9
,
10
]))
yaxis
.
set_minor_locator
(
mpl
.
ticker
.
MultipleLocator
(
30
))
def
add_scale
(
ax
,
scale
,
text
=
None
,
*
,
size
=
0.01
,
padding
=
0.1
,
loc
=
'
lower right
'
,
color
=
'
k
'
,
fontsize
=
'
x-small
'
):
"""
Make a scale or yardstick patch
"""
aux
=
mpl
.
offsetbox
.
AuxTransformBox
(
mpl
.
transforms
.
blended_transform_factory
(
ax
.
transData
,
ax
.
transAxes
))
aux
.
add_artist
(
plt
.
Rectangle
((
0
,
0
),
scale
,
size
,
fc
=
color
))
if
text
:
aux
.
add_artist
(
plt
.
Text
(
0
,
size
,
text
,
color
=
color
,
va
=
'
bottom
'
,
fontsize
=
fontsize
))
ab
=
mpl
.
offsetbox
.
AnchoredOffsetbox
(
loc
,
borderpad
=
padding
,
zorder
=
100
,
frameon
=
False
)
ab
.
set_child
(
aux
)
ax
.
add_artist
(
ab
)
...
...
@@ -181,8 +195,6 @@ def plot_btf(axf, axp, data, *, frev=None, **kwargs):
axf
.
set
(
ylabel
=
f
'
Magnitude /
{
data
.
m_unit
}
'
,
xlim
=
(
np
.
min
(
f
),
np
.
max
(
f
)))
axp
.
set
(
ylabel
=
f
'
Phase /
{
data
.
p_unit
}
'
,
xlabel
=
'
Stimulus tune
'
if
frev
else
f
'
Stimulus frequency /
{
data
.
f_unit
}
'
)
return
fig
,
(
af
,
ap
)
def
plot_tune_spectrum
(
ax
,
libera_data
,
xy
,
turn_range
=
None
,
time_range
=
None
,
tune_range
=
None
,
fit
=
False
,
smoothing
=
None
,
return_spectrum
=
False
,
**
kwargs
):
...
...
@@ -219,6 +231,7 @@ def plot_tune_spectrum(ax, libera_data, xy, turn_range=None, time_range=None, tu
ylabel
=
'
a.u.
'
)
if
fit
:
q
=
None
try
:
fitr
=
(
fit
if
callable
(
fit
)
else
fit_lorenzian
)(
freq
,
mag
)
q
,
w
=
fitr
[
0
][
2
],
fitr
[
0
][
3
]
...
...
@@ -350,7 +363,7 @@ def plot_tune_spectrogram(ax, libera_data, xy, *, nperseg=2**12, noverlap=None,
ax
.
get_figure
().
colorbar
(
cm
,
label
=
'
FFT magnitude
'
,
ax
=
ax
)
if
show_nperseg
and
not
over_time
:
a
x
.
plot
(
ax
.
get_xlim
()[
1
]
*
0.97
-
np
.
array
((
nperseg
,
0
)),
[
0.05
,
0.05
],
'
k|--
'
,
transform
=
ax
.
get_xaxis_text1_transform
(
0
)[
0
]
)
a
dd_scale
(
ax
,
nperseg
)
# indicate excitation region
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment