Skip to content

Commit

Permalink
Update docs; bugfix in vowelplot
Browse files Browse the repository at this point in the history
  • Loading branch information
maetshju committed Dec 28, 2023
1 parent 0c47eec commit 61fea22
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
9 changes: 6 additions & 3 deletions docs/src/phon_spectrogram.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Spectrograms

A basic function is provided to plot spectrograms that look familiar to phoneticians. It makes use of the `spectrogram` function from `DSP.jl` to perform the short-time Fourier analysis.
A basic function is provided to plot spectrograms that look familiar to phoneticians. It makes use of the `spectrogram` function from `DSP.jl` to perform the short-time Fourier analysis. The plot specification is given using `RecipesBase.jl` to avoid depending on `Plots.jl`. It is necessary to specify `using Plots` before spectrograms can be plotted.

## Examples

Expand All @@ -9,6 +9,7 @@ A standard broadband spectrogram can be created without using optional parameter
```@example
using Phonetics # hide
using WAV
using Plots
s, fs = wavread("assets/iwantaspectrogram.wav")
s = vec(s)
phonspec(s, fs)
Expand All @@ -21,7 +22,7 @@ using Phonetics # hide
using WAV # hide
s, fs = wavread("assets/iwantaspectrogram.wav") # hide
s = vec(s) # hide
using Plots
using Plots # hide
phonspec(s, fs, col=:binary)
```

Expand All @@ -32,6 +33,7 @@ using Phonetics # hide
using WAV # hide
s, fs = wavread("assets/iwantaspectrogram.wav") # hide
s = vec(s) # hide
using Plots # hide
phonspec(s, fs, style=:narrowband)
```

Expand All @@ -40,6 +42,7 @@ And, the pre-emphasis can be disabled by passing in a value of 0 for the `pre_em
```@example
using Phonetics # hide
using WAV # hide
using Plots # hide
s, fs = wavread("assets/iwantaspectrogram.wav") # hide
s = vec(s) # hide
phonspec(s, fs, pre_emph=0)
Expand All @@ -48,5 +51,5 @@ phonspec(s, fs, pre_emph=0)
# Function documentation

```@docs
phonspec(s::Vector, fs; pre_emph=0.97, col=:magma, style=:broadband, dbr=55, size=(600, 400))
phonspec
```
17 changes: 8 additions & 9 deletions docs/src/vowelplot.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Vowel plotting

The function provided for plotting vowels diplays offers a variety of visualization techniques for displaying a two-dimensional plot for vowel tokens. Traditionally, it is F1 and F2 that are plotted, but any two pairs of data can be plotted, such as F2 and F3, F2-F1 and F3, etc. A traditional, vanilla vowel plot only requires three positional arguments, `f1`, `f2`, and `cats`. Other plotting arguments that the `Plots` package can accept will be passed through to the first call to `plot`.
The function provided for plotting vowels diplays offers a variety of visualization techniques for displaying a two-dimensional plot for vowel tokens. Traditionally, it is F1 and F2 that are plotted, but any two pairs of data can be plotted, such as F2 and F3, F2-F1 and F3, etc. A traditional, vanilla vowel plot only requires three positional arguments, `f1`, `f2`, and `cats`. The plot specification is given using `RecipesBase.jl` to avoid depending on `Plots.jl`. It is necessary to specify `using Plots` before spectrograms can be plotted.

```@example
using Phonetics # hide
using Plots # hide
using Plots
data = generateFormants(30, gender=["w"], seed=56) # hide
vowelPlot(data.f1, data.f2, data.vowel, xlab="F1 (Hz)", ylab="F2 (Hz)")
vowelplot(data.f1, data.f2, data.vowel, xlab="F1 (Hz)", ylab="F2 (Hz)")
savefig("vanilla_vowel_plot.svg") # hide
nothing # hide
```
Expand All @@ -20,7 +20,7 @@ For those inclined to use the alternate axes configuration with F2 decreasing on
using Phonetics # hide
using Plots # hide
data = generateFormants(30, gender=["w"], seed=56) # hide
vowelPlot(data.f2, data.f1, data.vowel,
vowelplot(data.f2, data.f1, data.vowel,
xflip=true, yflip=true, xlab="F2 (Hz)", ylab="F1 (Hz)")
savefig("alt_axes_vowel_plot.svg") # hide
nothing # hide
Expand All @@ -36,7 +36,7 @@ The `vowelPlot` function also allows for ellipses to be plotted around the value
using Phonetics # hide
using Plots # hide
data = generateFormants(30, gender=["w"], seed=56) # hide
vowelPlot(data.f1, data.f2, data.vowel, ell=true, ellPercent=0.67,
vowelplot(data.f1, data.f2, data.vowel, ell=true, ellPercent=0.67,
xlab="F1 (Hz)", ylab="F2 (Hz)")
savefig("ellipse_vowel_plot.svg") # hide
nothing # hide
Expand All @@ -52,7 +52,7 @@ One final feature to point out is that the `vowelplot` function can also plot ju
using Phonetics # hide
using Plots # hide
data = generateFormants(30, gender=["w"], seed=56) # hide
vowelPlot(data.f1, data.f2, data.vowel, ell=true,
vowelplot(data.f1, data.f2, data.vowel, ell=true,
meansOnly=true, addLabels=true, xlab="F1 (Hz)", ylab="F2 (Hz)")
savefig("means_only_ellipse_vowel_plot.svg") # hide
nothing # hide
Expand All @@ -65,12 +65,11 @@ The labels are offset from the mean value a bit so as to not cover up the marker
## Function documentation

```@docs
vowelPlot(f1, f2, cats; [meansOnly=false, addLabels=true, ell=false,
ellPercent=0.67, nEllPts=500, markersize=1, linewidth=2, kw...])
vowelplot
```

```@docs
ellipsePts(f1, f2; percent=0.95, nPoints=500)
ellipsePts
```

## References
Expand Down
4 changes: 2 additions & 2 deletions src/Phonetics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ include("sound.jl")
export Sound

include("VowelDensity.jl")
export Formants, VowelSpace, plot, plot!, area, vdi
export Formants, VowelSpace, area, vdi, vowelspaceplot

include("normalize.jl")
export neareyE, neareyI, lobanov, formantWiseLogMean, nearey1, logmeanI, formantBlindLogMean, nearey2, logmeanE

include("vowelplot.jl")
export vowelPlot, ellipsePts
export vowelplot, ellipsePts

include("acdist.jl")
export acdist, avgseq, distinctiveness, sound2mfcc
Expand Down
4 changes: 2 additions & 2 deletions src/vowelplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using LinearAlgebra
using Distributions

"""
vowelPlot(f1, f2, cats; [meansOnly=false, addLabels=true, ell=false, ellPercent=0.67, nEllPts=500, kw...])
vowelplot(f1, f2, cats; [meansOnly=false, addLabels=true, ell=false, ellPercent=0.67, nEllPts=500, kw...])
Create an F1-by-F2 vowel plot. The `f1` values are displayed along the x-axis, and the `f2` values are displayed along the y-axis, with each unique vowel class in `cats` being represented with a new color. The series labels in the legend will take on the unique values contained in `cats`. The alternate display whereby reversed F2 is on the x-axis and reversed F1 is on the y-axis can be created by passing the F2 values in for the `f1` argument and F1 values in for the `f2` argument, and then using the `:flip` magic argument provided by the `Plots` package.
Expand Down Expand Up @@ -79,7 +79,7 @@ vowelplot
seriestype := :scatter
markersize := 0
label := ""
series_annotations := [(mns.cat[i], palette(:auto)[i]) for i in 1:size(mns, 1)]
series_annotations := [mns.cat[i] for i in 1:size(mns, 1)]
mns.f1_mean .+ jt1, mns.f2_mean .+ jt2

Check warning on line 83 in src/vowelplot.jl

View check run for this annotation

Codecov / codecov/patch

src/vowelplot.jl#L76-L83

Added lines #L76 - L83 were not covered by tests
end
end
Expand Down

0 comments on commit 61fea22

Please sign in to comment.