diff --git a/docs/src/phon_spectrogram.md b/docs/src/phon_spectrogram.md index 9206c7d..8080e20 100644 --- a/docs/src/phon_spectrogram.md +++ b/docs/src/phon_spectrogram.md @@ -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 @@ -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) @@ -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) ``` @@ -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) ``` @@ -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) @@ -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 ``` \ No newline at end of file diff --git a/docs/src/vowelplot.md b/docs/src/vowelplot.md index 1483502..a3ea009 100644 --- a/docs/src/vowelplot.md +++ b/docs/src/vowelplot.md @@ -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 ``` @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/src/Phonetics.jl b/src/Phonetics.jl index 8b3a59e..21bd01b 100644 --- a/src/Phonetics.jl +++ b/src/Phonetics.jl @@ -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 diff --git a/src/vowelplot.jl b/src/vowelplot.jl index 4dfdf74..3b80982 100644 --- a/src/vowelplot.jl +++ b/src/vowelplot.jl @@ -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. @@ -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 end end