spectro
.ggspectro(wave, f, tlab = "Time (s)",
flab = "Frequency (kHz)", alab = "Amplitude(dB)", ...) - wave
{an R object.}
- f
{sampling frequency of wave
(in Hz). Does not need to be specified if embedded in wave
.}
- tlab
{label of the time axis.}
- flab
{label of the frequency axis.}
- alab
{label of the amplitude axis.}
- ...
{other non-graphical arguments to be passed to spectro
(wl
, ovlp
etc).}
This function return the fist layer (data and aesthetic
mapping) of a ggplot2 plot.
See the example section to understand how to build a spectrogram and consult ggplot2 help to get what you
exactly need.
There is no way to plot the oscillogram as spectro does.
A ggpot layer.
Wickham H (2009) -- ggplot2: elegant graphics for data analysis. UseR! Springer.
[object Object]
This function requires ggplot2 package.
require(ggplot2)
## first layer
v <- ggspectro(tico, ovlp=50)
summary(v)
## using geom_tile ##
v + geom_tile(aes(fill = amplitude)) + stat_contour()
## coordinates flip (interest?)
v + geom_tile(aes(fill = amplitude)) + stat_contour() + coord_flip()
## using stat_contour ##
# default (not nice at all)
v + stat_contour(geom="polygon", aes(fill=..level..))
# set up to 30 color levels with the argument bins
(vv <- v + stat_contour(geom="polygon", aes(fill=..level..), bins=30))
# change the limits of amplitude and NA values as transparent
vv + scale_fill_continuous(name="Amplitude\n(dB)\n", limits=c(-30,0), na.value="transparent")
# Black-and-white theme
(vv + scale_fill_continuous(name="Amplitude\n(dB)\n", limits=c(-30,0),
na.value="transparent", low="white", high="black") + theme_bw())
# Other colour scale (close to spectro() default output)
v + stat_contour(geom="polygon", aes(fill=..level..), bins=30)
+ scale_fill_gradientn(name="Amplitude\n(dB)\n", limits=c(-30,0),
na.value="transparent", colours = spectro.colors(30))
dplot
ts