-
Notifications
You must be signed in to change notification settings - Fork 12
/
recipes.jl
65 lines (54 loc) · 1.97 KB
/
recipes.jl
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
54
55
56
57
58
59
60
61
62
63
64
65
# Unit "plots" of the FourierAnalysis Package for julia language
#
# MIT License
# Copyright (c) 2019-2020, Marco Congedo, CNRS, Grenobe, France:
# https://sites.google.com/site/marcocongedo/home
# ? CONTENTS :
# This unit implements recipes for plotting data generated
# by FourierAnalysis without having any dependency to plot
# packages
########################################################
@recipe function f(::Type{Taper}, taper::Taper)
title --> taperinfo(taper)
legend --> false
dpi --> 300
background_color --> :white
gridcolor --> :white
taper.y
end
@recipe function f(::Type{Spectra}, S::Spectra;
fmax = S.sr/2,
xspace = 4,
ytitle = "Power (\\muV²)")
b=f2b(fmax, S.sr, S.wl)
xticstring=["$(xspace*i)" for i=1:fmax÷xspace]
pushfirst!(xticstring, "$(fres(S.sr, S.wl))")
xticrange=[1:S.wl/S.sr*xspace:b+1;]
for i=2:length(xticrange) xticrange[i]=xticrange[i]-1 end
legend --> false
dpi --> 300
xlabel --> "Frequency (Hz)"
xticks --> (xticrange, xticstring)
ylabel --> ytitle
delete!(plotattributes, :fmax)
delete!(plotattributes, :xspace)
delete!(plotattributes, :ytitle)
S.y[1:(f2b(fmax, S.sr, S.wl; DC=S.DC)), :]
end
"""
Generate labels for the axes to be used in heatmap plots of [TFobjects](@ref).
On the y-axis the labels correspond to the center frequencies of the band-pass
filter bank used to obtain the time-frequency representation, that is,
to the `.flabels` field of the object.
See [plot time-frequency objects](@ref) for examples.
"""
function tfAxes(Y::TFobjects)
function formatf(r::Real)
s="$r"
ss=split(s, ".")
length(ss)>1 && parse(Float64, ss[2])==0.0 ? (return ss[1]) : (return s)
end
xs = [string(i) for i = 1:size(Y.y, 2)]
ys = Vector{String}([formatf(f) for f in Y.flabels])
return xs, ys
end