tags:

views:

212

answers:

1

I am using the EMD package for R. This package has a spectrogram function for displaying a Hilbert Spectrum (calculated with hilbertspec). The output however, is really vague and black-white.

This function does not seem to have an option for outputting color images. How can I get the spectrum displayed clearly and if possible in color.

+3  A: 

The gray levels are hardcoded in the spectrogram function (gray()), to override this setting you could use, for instance, the following:

# define a color palette
colors <- colorRampPalette(c("#007FFF", "blue", "#000077"))  
gray <- function(x) colors(255*x)  # redefine gray palette
spectrogram(test1$amplitude[,1], test1$instantfreq[,1])
gray <- grDevices::gray  # reset gray palette function

Another option is to use the source of the spectrogram function to define your own plot function which has an argument for the color palette.

rcs