PlotImage <- function (inAuditoryImage)
{
if (class(inAuditoryImage) != "ANI") {
stop("Object must be of class ANI.")
}
message("Large ANI can delay. Please, wait...")
suppressMessages(require(reshape2))
if (names(inAuditoryImage)[1] == "AuditoryNerveImage") {
AI <- inAuditoryImage$AuditoryNerveImage
mAI <- melt(AI)
mAI$Var1 <- 1:dim(inAuditoryImage$AuditoryNerveImage)[1]
mAI$Var2 <- mAI$Var2/100
} else {
AI <- inAuditoryImage$PeriodicityPitchImage
mAI <- melt(AI)
mAI$Var1 <- inAuditoryImage$Periods
mAI$Var2 <- mAI$Var2/100
}
suppressMessages(require(ggplot2))
Plot.AI <- ggplot(mAI, aes(x = Var2, y = Var1)) +
geom_raster(aes(fill=value)) +
scale_fill_gradient(low="blue", high="gold1") +
labs(x="Time (in s)", y="Periods (in s)", title="Periodicity pitch") +
theme_bw() + theme(axis.text.x=element_text(size=9, angle=0, vjust=0.3),
axis.text.y=element_text(size=9),
plot.title=element_text(size=11))
return(Plot.AI)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.