Created
September 26, 2015 14:28
-
-
Save pepijn-devries/5d7ef694c42b08bcf302 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# select a sample: | |
plot_samp <- PTSample(mod, 25) | |
# generate power spectrum | |
spec <- powspec(waveform(plot_samp), | |
wintime = 0.1, | |
steptime = 0.005) | |
spec_cutoff <- quantile(log10(spec), 0.01) | |
spec[log10(spec) < spec_cutoff] <- 10^spec_cutoff | |
# fancy 3D plot of waveform and powerspectrum | |
png("powerspec.png", 600, 300, type = "cairo", | |
bg = "transparent", pointsize = 14) | |
par(oma = c(0,0,0,0), mar = c(0.5,0.5,0.5,0.5)) | |
lines3D(x = 60*(0:(length(plot_samp) - 1))/(length(plot_samp) - 1), | |
y = rep(15, length(plot_samp)), | |
z = 3 + 11*waveform(plot_samp)/255, | |
phi = 40, theta = 21, lwd = 0.15, | |
xlim = c(0,60), ylim = c(0,15), zlim = c(-3, 14.5), | |
xlab = "time", ylab = "Frequency", zlab = "Amplitude", | |
col = "black", lwd = 0.5, scale = F, bty = "b2") | |
persp3D(x = 60*((1:ncol(spec)) - 1)/(ncol(spec) - 1), | |
y = 15*((1:(nrow(spec) - 3)) - 1)/(nrow(spec) - 4), | |
z = t(log10(spec))[,-(1:3)], | |
xlab = "time", ylab = "Frequency", zlab = "Amplitude", | |
add = T, colkey = F, shade = 0.1) | |
dev.off() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment