From 7247d71b674162f5dcb59ef729b714eca9ede8ff Mon Sep 17 00:00:00 2001 From: Michel Crucifix <michel.crucifix@uclouvain.be> Date: Wed, 9 Oct 2024 18:56:40 +0200 Subject: [PATCH] fixed labels in mffh plot --- R/mfft_support.R | 4 ++-- man/attributeTones.Rd | 37 +++++++++++++++++++++++++++++++++++++ man/toneCombinations.Rd | 28 ++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 man/attributeTones.Rd create mode 100644 man/toneCombinations.Rd diff --git a/R/mfft_support.R b/R/mfft_support.R index 733ce53..662afe4 100644 --- a/R/mfft_support.R +++ b/R/mfft_support.R @@ -62,8 +62,8 @@ plot.mfft_deco <- function (M,periods=FALSE,labels=NULL,...){ } points(abs(M$Freq), abs(M$Amp),'p',...) if (!is.null(labels)) { - yshift <- 0.2*range(M$Amp) - text(M$Freq, M$Amp + yshift, labels) + yshift <- 0.05*range(M$Amp) + text(M$Freq, M$Amp + yshift, labels, srt=90, pos=4) } } diff --git a/man/attributeTones.Rd b/man/attributeTones.Rd new file mode 100644 index 0000000..00f347d --- /dev/null +++ b/man/attributeTones.Rd @@ -0,0 +1,37 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/toneCombinations.R +\name{attributeTones} +\alias{attributeTones} +\title{Attribution of combination of tones} +\usage{ +attributeTones(infreq, omegas, tol1 = 1e-06, tol2 = 1e-04) +} +\arguments{ +\item{infreq}{: input frequencies} + +\item{omegas}{: reference frequencies (a numeric vector which may contain explicit row names)} + +\item{tol1}{: acceptable tolerance for being considered as a certain attribution +(if several frequencies match the criteria, the closest will be taken)} + +\item{tol2}{: acceptable tolerance for being considered as a likely or plausible} +} +\description{ +Based on a vector of frequencies (`infreq`), and a vector of referenc +frequencies with row names (it will be input to `toneCombinations`), +attribute the `infreq` frequencies with two possible degrees of tolerance +} +\examples{ +omegas <- c( 0.123, 0.14312, 0.33251, 0.554313) +names(omegas) <- c('g1','g2','s1','s2') +outamps <- c(1., 2, 0.2 , 0.5, 0.5) +outfreqs <- c(1., 1.2432, omegas[1]+omegas[3]+0.00000002, omegas[1]-omegas[4]+0.00004, 0.15) + +attributions <- attributeTones(outfreqs, omegas) + +cbind(outfreqs, attributions) + +plot(outfreqs, outamps, type='h') +text(outfreqs, outamps+0.1, attributions) + +} diff --git a/man/toneCombinations.Rd b/man/toneCombinations.Rd new file mode 100644 index 0000000..9be4371 --- /dev/null +++ b/man/toneCombinations.Rd @@ -0,0 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/toneCombinations.R +\name{toneCombinations} +\alias{toneCombinations} +\title{Generation of combination of tones} +\usage{ +toneCombinations(omegas, keepPositives = TRUE) +} +\arguments{ +\item{keepPositives}{: if TRUE, then only keeps positive combinations of frequencies} + +\item{omegas:}{vector of references frequencies, optionally with rownames,} +} +\value{ +a vector with combination of tones and explicit rownames, using, if available, the + rownames provided in the input vector omega +} +\description{ +Generates a vector with combinations of an input vector of frequencies, wih +explicit label names, up to order 3 (this could be made more flexible is the future) +} +\examples{ +omegas <- c( 0.123, 0.14312, 0.33251, 0.554313) +print(toneCombinations(omegas) +} +\author{ +Michel Crucifix +} -- GitLab